With the federal government shut down until further notice, many investors are wondering what this will mean for the stock market. General uncertainty can often result in market volatility, and there's plenty of uncertainty to go around right now. Nobody knows how long this shutdown will last or what type of agreement Congress will eventually reach on future funding.

That said, there's one fantastic reason to consider buying stocks right now -- and one other reason you might consider waiting.

Capitol building with closed sign in front of it.

Image source: Getty Images.

The case for investing right now

Perhaps the strongest argument for continuing to invest during the government shutdown is that the market's long-term potential is incredibly lucrative. There is a chance that the market could experience short-term volatility due to the shutdown, especially if it lasts weeks or even months. With hundreds of thousands of federal workers furloughed and layoffs potentially looming, government shutdowns can take a toll on the economy -- which can translate to market turbulence.

However, even if the market does take a turn for the worse, it's extremely likely to earn positive total returns over several years. Historically, the investors who have earned the most are the ones who stayed in the market through all the rough patches.

Let's look at an extreme example and say that, hypothetically, this shutdown leads to a recession on par with the financial crisis of 2007-2009. The Great Recession was the longest and most severe economic downturn post-WWII, with the S&P 500 (^GSPC 0.01%) losing more than half its value in a little over a year.

Investing in December 2007, right before the market began to plunge, may have seemed like the worst possible move at the time. However, since then, the S&P 500 has earned total returns of 343%.

^SPX Chart

^SPX data by YCharts.

To be clear, the next couple of years after the recession began would have been tough as your portfolio plummeted in value with no end in sight. But if you'd invested in an S&P 500-tracking fund back then, you'd have more than quadrupled your money by today.

Again, there's no way to know what the next few months or years will look like for the stock market. There's no guarantee that the government shutdown will in any way lead to a recession, let alone one as severe as the financial crisis of 2008.

Sometimes, though, looking at other downturns throughout history can be a helpful reminder that the stock market has survived tough times before. And investors with the potential to earn the most are the ones who maintain a long-term outlook.

One reason to avoid the stock market

As long as you're willing to stay invested for at least a few years (or, ideally, a decade or two), there's no reason not to continue buying stocks now. Even if the market plummets in the future, its long-term outlook is incredibly positive.

However, if you're not sure you can leave your money invested for the foreseeable future, it may not be the best time to buy. Market downturns are among the worst possible times to withdraw your money. If the market sinks in the coming weeks and you suddenly need that money, you risk selling your investments for far less than you paid for them -- locking in steep losses.

If you haven't done so already, now is the time to ensure you've got a few months' worth of savings stashed in an emergency fund. With at least some cash accessible to cover any unplanned expenses (or pay your bills in the unfortunate event of a job loss), it will be easier to keep your money in the market until stock prices eventually recover.

The government shutdown is causing plenty of uncertainty among investors, so if you're feeling nervous about the future, you're not alone. By building a healthy emergency fund and staying invested for the long haul, though, your portfolio is more likely to pull through whatever the market throws at it.