You win some and you lose some. For billionaire investor Bill Ackman of Pershing Square Capital Management, embattled drugmaker Valeant Pharmaceuticals (NYSE:BHC) may very well represent the worst investment of his lifetime after the billionaire announced yesterday that he'd sold out of Valeant.

Ackman and Pershing Square began investing in Valeant Pharmaceuticals when its stock was trading around $190 per share in 2015 and it could seemingly do no wrong. Valeant had exceptional pricing power on its pharmaceutical products, and it was a bustling merger and acquisition (M&A) engine that was financing new drug and company acquisitions with debt. Its growing debt levels seemed to be of little concern because its EBITDA (earnings before interest, taxes, depreciation, and amortization) continued to rise with each new deal.

In the summer of 2015, shortly after Valeant hit an all-time high of $264 a share, the wheels fell off the bus, and Ackman would be taken for the ride of his life.

Valeant's fall from grace

First, Valeant came under fire for its pricing practices on cardiovascular drugs Nitropress and Isuprel, which were acquired from Marathon Pharmaceuticals in Feb. 2015. Valeant admitted to raising the list prices on both products by 525% and 212%, respectively, without altering their formulation or manufacturing process. This admission by now-former CEO J. Michael Pearson led to Valeant losing a lot of its pricing power.

Next came the scandals. Valeant's relationship with Philidor Rx Services, an owned subsidiary, was questioned. In particular, federal prosecutors examined whether or not Philidor was acting as a neutral party between Valeant and insurers. If it was somehow showing partiality to Valeant's more expensive brand-name products, and executives knew about it, this would be a big problem. Ultimately, two former executives -- one from Valeant and one from Philidor -- were charged.

Next in line were Valeant's debt woes. With the company's pricing power becoming constrained and its EBITDA forecasts adjusted lower, creditors essentially cut off new debt deals. This brought the full weight of its $30 billion-plus in debt into view, and it frankly scared Wall Street and investors.

Valeant came to terms with the idea that it had little choice but to sell off its non-core assets, and perhaps its core assets, too, to pare down its debt in order to have better financial flexibility. The company has since reworked its debt covenants on multiple occasions, paying higher interest rates and fees in the process.

Finally, the company's core businesses began tumbling, one by one. Its flagship dermatology business was seeing year-over-year sales declines of more than 50%, while its branded Rx segment saw sales dip by 17% in the recently reported fourth quarter.

Put plainly, Valeant is a mess.

Ackman's glass-partially-full view

In many ways, Ackman will be criticized for his poor investment in Valeant Pharmaceuticals. Pershing Square was the second-largest investor in Valeant's stock at the end of the fourth quarter according to 13F filings, behind only Paulson & Co., and it's estimated that Ackman wound up losing nearly $4 billion in total on his investment in Valeant. (He had previously pared his funds' holdings in Valeant.)

However, selling Pershing Square's remaining 18.1 million shares now means walking away with about $221 million. That might seem like peanuts after losing nearly $4 billion, but Ackman deserves credit for realizing his mistake, checking his ego at the door, and walking away with $221 million rather than risk seeing his investment get further whittled down.

Why not let his investment ride if he's lost nearly 95%, you wonder? Simple: Ackman's investment thesis no longer held true.

Ackman bought into Valeant with the assumption that its mergers and acquisition (M&A) machine could make between $7 billion and $20 billion in annual acquisitions. He also strongly believed he was buying into a company with strong pricing power and a solid management team. None of these visions have proven accurate. Valeant's M&A machine was halted in its tracks, Valeant's pricing power went in reverse in the fourth quarter, and its new CEO Joseph Papa may have walked into an unfixable situation.

The biggest issue for Valeant Pharmaceuticals remains its debt covenants. Valeant is required to generate a specific amount more in EBITDA each year than it pays out to cover the interest on its debt. This EBITDA-to-interest coverage ratio has been readjusted on numerous occasions over the past year.

Based on the company's forecast for $3.55 billion to $3.7 billion in full-year EBITDA for 2017, and interest coverage of $1.85 billion, Valeant's EBITDA-to-interest coverage ratio is probably going to fall below two. That's dangerously low, and it may trigger a faster repayment of its debt if it heads any lower. Ackman probably realized this once he saw the Q4 report and made the decision to exit.

In hindsight, buying Valeant was a terrible move, but selling now is probably the smartest thing he could have done, given its bleak outlook. If Ackman has taught investors anything, it's that even the smartest investors are wrong from time to time, and that it's perfectly OK to sell an investment if it no longer matches your investment thesis. Personally, I believe Ackman made the right call.