Treasury Secretary Tim Geithner may want to consider hosting "Extreme Makeover" as his next gig.

After all, the American International Group Inc. rescue he helped engineer has come to a shiny, sparkling end with a reconstructed company that's so attractive an investment it's generating a profit for the U.S. government.

It's a Hollywood ending for a controversial rescue that many thought would never end -- or certainly not end well.

But what is the moral of this seemingly feel-good tale? Will AIG's experience perpetuate moral hazard and make Washington less afraid to ride to a financial firm's rescue? Or will the Dodd-Frank law that AIG's rescue spawned prevent a sequel?

This week, the Treasury Department said it will sell its remaining stake in AIG, bringing an end to the government's investment. The sale of 234 million shares at a price of $32.50 per share will help generate an overall $22.7 billion profit for the federal government. That amount stems from the holdings of both the U.S. Treasury and the Federal Reserve Bank of New York, which together extended AIG a $182 billion lifeline beginning in 2008.

But Washington's rescue conveyed an even bigger benefit than just generating a profit: It returned the giant insurer to its roots as a primarily sleepy insurance company, helping to suck risk out of the financial system. AIG, with the assistance of a government-orchestrated restructuring led by former Treasury official Jim Millstein, was able to shed its riskier assets and find solid financial footing.

AIG Chief Executive Officer Robert Benmosche, the former CEO of MetLife Inc., has sold many of the company's units, including its consumer-finance and Asian life-insurance operations, to help repay the government and simplify AIG, as Bloomberg News reports. This week, Benmosche agreed to sell an 80 percent stake in the insurer’s plane-leasing unit. As of Sept. 30, AIG had about $550 billion in assets, compared with more than $1 trillion at the end of 2007.

As Benmosche said in a letter to employees, Treasury's final share sale "marks our second act." The company will likely be regulated by the Federal Reserve as a "systemically important financial institution" and be required to hold higher levels of capital to counter any risk-taking.

Treasury, meanwhile, is expected to make $5 billion on its investment, and the Fed will earn a $17.7 billion profit. That's a fairly unexpected ending to a rescue that at times seemed bottomless and threatened to topple Geithner. The Treasury secretary, who headed the New York Fed when AIG was rescued, was blasted for not stopping bonus payments to AIG workers and for a decision allowing AIG to make counterparties, including Goldman Sachs Group Inc., whole.

Those criticisms will persist, but the makeover Geithner helped orchestrate turned AIG into a much prettier version of itself -- a version it probably could not have achieved absent the government's help.

(Deborah Solomon is a member of the Bloomberg View editorial board. Follow her on Twitter.)

Read more breaking commentary from Bloomberg View at the Ticker.