THE OBAMA administration announced Thursday that it would sell its remaining shares in General Motors by the end of the year, heralding an end to the largest direct government bailout of a U.S. industry in modern history. The U.S. government stands to lose $10 billion on its investment, based on GM’s current stock price. Combined with the Treasury Department’s already realized loss of $1 billion on its smaller investment in Chrysler, that brings the total cost to taxpayers of rescuing two of the Detroit Three to $11 billion.

Was it worth it? Anyone who claims a definitive answer to that question is not being honest. The government could have spent less on the bailout if it had driven a harder bargain with the autoworkers’ union, which made only modest concessions. But taxpayers would likely have ended up on the hook for a substantial amount anyway. That cost would have to be weighed against the costs of not intervening, which might have resulted in liquidation and a cascade effect throughout the auto industry supply chain. Not even financially healthy Japanese, German and Korean factories could have escaped that unscathed, to say nothing of the surrounding cities and towns. On the other hand, resources not devoted to propping up GM and Chrysler could have found alternative productive uses, perhaps yielding more jobs and other benefits to society in the long run.

Given the centrality of the auto industry, the depth of its problems and the dangers of allowing it to collapse at the height of the Great Recession, any government, Republican or Democratic, would probably have intervened. That’s a political reality, not an economic one. President Obama has claimed credit for saving GM, and justifiably so; but bridge loans extended by the Bush administration in its waning days kept GM and Chrysler alive long enough for Mr. Obama’s team to arrange the managed bankruptcy that ultimately occurred. And, all things considered, that restructuring has worked out better than many skeptics expected. GM is still too complex structurally, too dependent on trucks and SUVs commercially. But it turned a profit in the last 15 consecutive quarters, slashed its debt from $45.8 billion to $8.4 billion, reined in pension costs and renovated dealerships.

The Great Recession may have killed the old GM, but the company was susceptible because of bad corporate habits that had been accumulating for decades, like gunk in an old carburetor. By the time of its bankruptcy, GM was much more about satisfying the often conflicting demands of regulators, financiers, unions and its own corporate bureaucrats than it was about producing high-quality cars that customers wanted to buy. The government’s exit restores management’s freedom of action. But that liberated management can’t succeed if those who have a stake in GM resume putting their short-term demands — from higher wages and salaries to restored stock dividends — ahead of customers. History’s judgment of the bailout ultimately depends on what GM makes of its second chance; everyone involved, from Detroit to Washington to Wall Street, must behave accordingly.