The stock market is trading at all-time highs. Except for a minor loss in 2018, the S&P 500 has seen positive annual returns every year since 2009. If you believe that this is too good to be true and a crash is coming, you may be feeling nervous. 

No one wants to lose money, especially if you plan on using it soon. If a potential stock market crash has you panicked, make sure you do these four things. 

Woman looking at her laptop with a worried expression on her face.

Image source: Getty Images.

1. Control what you can 

There are things about investing that you can't control. For instance, you don't know when the next stock market crash will happen, you can't predict how long it will last, and you have no clue how severe it will be. Worrying about these things won't make them any less likely to happen.

Instead of being concerned about them, focus on what you can control. Make sure that you've evaluated your risk tolerance by taking a simple quiz, which can help ensure that you're not taking on more risk than you can handle. It will also help you pick the right asset-allocation model, which can play a major role in how much you lose (or don't lose) in the event of a crash.

Diversifying and owning a little bit of a lot of different stocks can also help you reduce losses. When you buy individual stocks, you're exposing yourself to concentrated risk, which could work out really well or really badly. From year to year, certain stocks are top performers and others can lose a lot of money. By spreading out your holdings over different companies, you don't have to guess from year to year what will do well and what won't.

2. Focus on your long-term goals

If the stock market crashes, it could potentially take years to recover. That's why it's smart not to make immediate plans to spend any money you've invested in stocks. But if you have a longer time horizon, you can afford to weather the ups and downs of the market.

For instance, if you had put $10,000 into large-cap stocks 20 years ago at the beginning of 2001 and needed the money at the end of that year, you would've lost nearly $1,200 of your money. By the beginning of 2006, it would've been worth $10,274. But however, you didn't plan on using your accounts until 2020, the value of that $10,000 would've grown to more than $42,000..

3. Shut out the noise

There are multiple indicators, like the Shiller price-to-earnings (P/E) ratio, that are currently pointing to an overvalued stock market. This indicator is currently at 35, and historically, a pullback has happened when it's reached 30 or higher. This happened just before the Great Depression and also in the late 1990s leading up to the dotcom crash. But this indicator wasn't valued this high just before the financial crash in 2008, so it's not always a warning signal.

These indicators also don't always mean that the worst-case scenario will happen. There have been several times when the market did pull back, but quickly recovered. For this reason, making decisions about how your portfolio is invested based solely on these types of predictions should be avoided. 

4. Remember past stock market crashes

Crashes are a part of stock market cycles, and there's never been one in history that has gone on indefinitely. In the 40-year period between 1980 and 2020, large-cap stocks experienced losses at the end of a calendar year seven times and gained money in 33 calendar years -- almost five times as often as they lost money! And of the seven years of losses, investors only experienced double-digit losses three times. If you're thinking of selling out of your investments so that you can miss these few bad years, just remember that you could also miss out on some of the good years, as well. 

Although your fears of losing money may get heightened during a bear market, you shouldn't worry. Crashes are inevitable, and avoiding one completely will be difficult, if not impossible. Keeping your cool and not letting your emotions get the best of you is the best strategy and can help you crush your long-term goals. 

This article represents the opinion of the writer, who may disagree with the “official” recommendation position of a Motley Fool premium advisory service. We’re motley! Questioning an investing thesis -- even one of our own -- helps us all think critically about investing and make decisions that help us become smarter, happier, and richer.