The U.S. government ended up losing $10.5 billion on the General Motors bailout, but it says the alternative would have been far worse.
The Treasury Department sold its final shares of the Detroit auto giant on Monday, recovering $39 billion of the $49.5 billion it spent to save the dying automaker at the height of the financial crisis five years ago.
Without the bailout, the country would have lost more than 1 million jobs, and the economy could have slipped from recession into a depression, Treasury Secretary Jacob Lew said on a conference call with reporters.
"The economic stakes were high, and President Obama understood that inaction was not an option," Lew said. "His decision to commit additional support to GM while requiring them to fundamentally restructure their business was tough but it was right."
The government received 912 million GM shares, or a 60.8 percent stake, in exchange for the bailout in 2008 and 2009. It began selling shares once GM went public again in November of 2010, and the pace picked up this year as the stock rose more than 40 percent.
Last month, the government said it expected to sell the remaining 2 percent stake by the end of the year.
(Read more: Kyle Bass takes stake in 'undervalued' GM)
GM shares rose 73 cents, or 1.8 percent in after-hours trading following the announcement. They rose 1.8 percent in regular trading, at one point reaching $41.17, the highest level since GM's 2010 initial public offering.
(What's the stock doing now? Click here).
Earlier Monday, Mark Reuss, GM's North American president, told reporters in Warren, Mich., that a government exit would boost sales, especially among pickup truck buyers.