It's not easy to be an investor right now. With stock prices tumbling and some experts warning that a recession could be looming, many people are questioning just how safe the stock market is at the moment.

Nobody knows for certain how long this downturn might last, and that uncertainty can be tough to stomach. Is it safer to pull your money out of the market? Or are you better off continuing to invest? Here's what history has to say.

Person with a serious expression sitting on a couch.

Image source: Getty Images.

The risks of withdrawing your investments

Pulling your money out of the market may seem like the safe option. After all, if stock prices continue to plummet, withdrawing your investments now could prevent you from losing even more.

However, because the market has already dipped considerably, selling your stocks now could lock in those losses.

The S&P 500 is down more than 24% since its peak in early January, and the tech-heavy Nasdaq has dropped by more than 32% in that timeframe. If you withdraw your money now, you'll likely be selling your investments for much less than you paid for them.

Then, if you decide to reinvest later once the market has stabilized, you could potentially lose even more money. By investing after stock prices have rebounded, you'll be paying higher prices for the same stocks you just sold.

Why the market is safer than it may seem

Right now, the stock market may seem anything but safe. While it's true that it can be volatile in the short term, it's been incredibly consistent over the long run.

In the last two decades alone, the market has experienced loads of ups and downs -- and some severe recessions. During the dot-com bubble burst in the early 2000s, for example, the S&P 500 fell by nearly 50%. Throughout the Great Recession, it plummeted by a staggering 57%.

^SPX Chart

^SPX data by YCharts

Despite everything, though, the S&P 500 is still up by more than 147% since 2000. While every downturn is different and nobody knows exactly how this slump will pan out, it's extremely likely the market will go on to see positive average returns over time.

The market rewards those who stay invested

Staying invested in the stock market during periods of volatility isn't easy. But it is one of the best ways to generate long-term wealth.

If there's one takeaway from market downturns, it's that losing value is not the same as losing money. Your portfolio has probably already lost value, and if stock prices continue to sink, your investments' value could fall even further.

However, you won't actually lose any money unless you sell your stocks. As long as you stay invested until the market rebounds, your portfolio should bounce back and you won't have lost anything. As a bonus, if you continue to invest when stock prices are at their lowest, you could see substantial returns when the market recovers.

The key is to ensure you're choosing solid long-term investments. Not all stocks will survive a recession. But when you fill your portfolio with stocks from strong companies, you're far more likely to make money over time -- even in the face of a market downturn.