We’re witnessing the fall of an American icon. Sears Holdings Corp. filed for Chapter 11 bankruptcy on Oct. 15. The 132-year-old retailer is now fighting for its life, hoping to avoid liquidation by creditors.

About 68,000 American jobs are at stake. If the creditors agree to a deal, Sears could keep its doors open. But the company is burning $125 million in cash per month, and hundreds of vendors have stopped shipping merchandise to Sears stores for fear they won’t be paid.

The story of Sears is a tragic tale of mismanagement and billions of dollars lost. It’s also a cautionary tale — an example of the incredibly high costs that come with nursing a bad investment.

Eddie Lampert, the billionaire hedge fund wizard who merged Kmart and Sears in 2005, was once seen as the deal-making heir to Warren Buffett. In the eyes of investors, he could do no wrong.

But with the Sears merger, Lampert made the worst investment of his life and spent the next 13 years mired in that mistake. Now Lampert has been forced out as CEO and Sears is on life support. And the pain isn’t over yet.

The broad lesson here for investors is that you always want an exit strategy. The larger the investment, the more important it is to know the stakes and to know in advance the circumstances in which you would sell, cut losses, or walk away.

If you don’t plan this out in advance, it’s far too easy to get sucked in, and before you know it, the consequences have spiraled out of control. Let’s take a closer look at how the Sears and Lampert story played out.

Sears was once the mightiest retailer around — the Amazon and Walmart of its day. In the year 1900, Sears sent its catalog to 20 million Americans. That was more than 25% of the population at the time. Adjusted for the 2018 population that would be 84 million people today — nearing the same ballpark as Amazon Prime membership.

The Sears catalog was once known as the “Wish Book” or “Big Dream Book.” It could run as long as 1,500 pages with more than 100,000 items for sale.

The genius of Sears’ co-founder, Richard Warren Sears, was exploiting two new technologies of the time: The railroad network and the U.S. Postal Service.

The USPS began rural free delivery in 1896, putting every American within reach of the Sears catalog. It was kind of the original internet, 100 years before the internet existed.

Sears expanded into brick-and-mortar retail stores in the 1920s, following Americans from rural areas into urban cities. After World War II, it colonized suburban shopping malls, and in the 1980s, Sears expanded into insurance (Allstate), credit cards (Discover), and stock brokerage services (Dean Witter).

But by the 1990s, Walmart and specialty big box stores (like Toys R Us and Bed Bath & Beyond) were eating Sears’ lunch. In 1993, Sears decided to close its warehouses and shut down the catalog. A year later, Amazon.com was born.

By the time Lampert came along, Sears was in trouble, but it still had some fight left in it.

Lampert was seen as one of the all-time great investors and dealmakers. He had worked in warehouses as a teenager, got into Yale, and then cut his teeth under the legendary Bob Rubin at Goldman Sachs.

While still at Goldman Sachs, Lampert did an intense study of the world’s best investors. For example, he scrutinized every deal Warren Buffett ever made, and then started his own hedge fund, ESL Investments.

Thanks to some concentrated stock bets that turned into huge winners, Lampert was a billionaire by age 41. He then pulled off his greatest deal ever in the early 2000s: Leading Kmart out of bankruptcy.

Kmart had fallen on hard times, filing for a $6 billion bankruptcy in 2002. Lampert’s hedge fund took control of the bankruptcy process with board seats and more than 50% of the shares.

After bringing Kmart out of bankruptcy, Lampert started closing stores and reducing cash burn. Kmart’s share price shot up more than 600% in a year as a result of these moves.

Lampert personally made hundreds of millions. Investors in his hedge fund made billions. Everyone was ecstatic.

It’s easy to see why he had confidence in himself prior to the Sears debacle.

He was one of the best deal-makers ever — as declared on the front page of multiple business magazines. He even negotiated his way out of his own kidnapping in 2003 during the middle of the Kmart deal.

When Lampert decided to merge Kmart and Sears in 2005 — an $11 billion deal — the assumption is that he would repeat the Kmart magic all over again, using financial engineering and cost streamlining to drive the Sears share price up 500 or 1,000%.

Instead, the whole Sears journey was a slow-rolling nightmare. In taking on Sears, Lampert bit off more than he could chew. The business had been in decline for decades by the time he took it over. And everything he did to try and fix the business made it worse.

Between 2005 and 2012, Sears had four different CEOs, all of whom were fired. Then the board installed Lampert himself as CEO. This was a disaster; he was a hedge fund guy, not a retail CEO.

In 2008, Lampert reorganized Sears into 30 separate divisions. The culture was described as “warring tribes,” with each division competing against the others. He managed the dozens of divisions from his $38 million mansion in Florida.

There was no cooperation. The stores were left in shabby disarray; remodeling was avoided to save money.

Eventually Lampert began selling off Sears’ various brands and real estate holdings, strip-mining the business for profitable parts.

In the end, nobody was happy. For all the cash Lampert pulled out of Sears, the share price decline was a disaster for his hedge fund investors. The deal in 2005 valued Sears at $11 billion. In its bankruptcy filing, Sears valued itself at just $6.9 billion in assets with $11 billion in liabilities.

Lampert is still a billionaire and may yet book a personal profit from Sears by the time all is said and done. He still controls the Sears’ corpse as it goes through the bankruptcy process, and there are still valuable parts and pieces to extract.

There are takeaways here other than “Don’t buy a dying retailer in the age of the internet.”

For investors, the main lesson is: Always have an exit strategy for any big investment that you make. Know the high costs of nursing a bad investment, and then try to avoid those costs like the plague.

Having an exit strategy doesn’t need to be complicated. A shorthand version is just knowing what would make you sell an investment, cut your losses, or otherwise walk away.

For example, commit in advance to a thesis, a benchmark trigger, or a stop loss, and then take action if one of those says, “Get out.”

Committing to a thesis means knowing the reason you’ve made an investment and walking away if the reason stops holding true.

If you buy a growth stock because of a rising trend in quarterly earnings and then earnings fail to keep trending higher, the thesis is broken and it’s time to sell.

A benchmark trigger means knowing in advance that, if event X happens as defined by a benchmark, you will get out. For example: “If this stock enters the red zone in my TradeStops portfolio, I will sell it.”

And a stop loss is just setting a simple price point: “If the shares decline by X price, I will sell.”

If Eddie Lampert, a billionaire who was once on track to become one of the greatest investors of all time, can make such a colossal mistake with a bad investment like Sears, then we can make big mistakes, too.

Don’t get burned by the high costs of nursing a bad investment. Take a page from Sears and Eddie Lampert and know in advance the conditions under which you will sell or walk away.