With the market up nicely in recent months, a lot of scared investors are wondering if it's time to head for the exits. But if you do, you'll have plenty of long-term investors thanking you -- because you'll be making the worst mistake you could possibly make, and a decision that will inevitably benefit those who stick with their investing plans.

Quitting on stocks is exactly the decision many investors made a few generations ago in response to the stock market collapse during the Great Depression. Having gone through the market crash of 1929 themselves -- or having learned about it from their parents -- millions of investors vowed never to invest in stocks again. Doing so proved to be the biggest wealth-destroying decision possible.

Cataloguing the damage
Of course, long-term stock investors have gone through a lot over the past couple of years. Unlike some past bear markets, where certain sectors proved much more vulnerable to large drops than others, investors have had few places to hide this time around. Just about every sector of the stock market has had at least some companies suffer big losses. Take a look:

Sector

Stock

2-Year Total Return

Energy

Valero Energy (NYSE:VLO)

(69.5%)

Technology

Dell (NASDAQ:DELL)

(57.6%)

Financial

Citigroup (NYSE:C)

(92.6%)

Utilities

Constellation Energy (NYSE:CEG)

(67.8%)

Health Care

Cigna

(60.4%)

Telecommunications

Sprint Nextel (NYSE:S)

(77.4%)

Industrials

Alcoa (NYSE:AA)

(76.3%)

Consumer Goods/Services

Sears Holdings (NASDAQ:SHLD)

(68.5%)

Source: Yahoo! Finance.

Nobody likes to put their money in a no-win situation. Yet that's exactly what you've had to deal with since late 2007. Pretty much the only way to avoid losses was to get out of the stock market entirely -- but even retreating to bonds was risky, unless you didn't settle for anything less than top-quality Treasuries.

Yet history has shown that following similarly dark periods in our financial history, stocks have done extremely well. One reason for this has to do with supply and demand.

Picking the cream of the crop
As counterintuitive as it may seem, long-term investors shouldn't be happy when everyone's buying stocks. Even though the high stock prices that result from increased demand may make your portfolio value rise temporarily, they also make it more costly for you to buy new shares. Just ask anyone who bought shares throughout 2006 and 2007 whether they were happy to pay premium prices on stocks that aren't anywhere near recovering to their former levels.

In contrast, long-term investors now have their pick from a smorgasbord of great companies, most of which are trading at much lower prices than they fetched during the bull market. And in order to make that last as long as possible, you should actually be rooting for other investors not to get back into stocks -- because that'll give you more time to scoop up as many bargains as you can.

For some evidence, look back to the booming stock markets of the 1940s and 1950s. Those periods coincided with the postwar economic boom -- and those predominantly skeptical Depression-era investors on the sidelines did their part to help keep share prices lower than they otherwise would've been, giving those who did scoop up stocks early some of the best long-term returns the market ever generated.

Don't panic
If stocks seem incredibly scary to you, that's perfectly understandable. But it's not a good reason to do an about-face on your investing strategy right now. Especially if you've got a good 10 or 20 years to go before you'll need to start taking money from your investments to support yourself, getting out of stocks today at levels that are still relatively low could be your biggest regret when you look back a decade or two from now.

For more on investing in stocks, read about:

Learn more about smart stock investing from Fool co-founders Tom and David Gardner in their Motley Fool Stock Advisor newsletter. Market-beating recommendations, in-depth analysis, and much more are yours free with a 30-day trial.

Fool contributor Dan Caplinger won't give up on stocks anytime soon. He doesn't own shares of the companies mentioned in this article. Dell, Sprint Nextel, and Sears Holdings are Motley Fool Inside Value selections. Try any of our Foolish newsletters today, free for 30 days. The Fool's disclosure policy isn't going anywhere.