When the COVID-19 outbreak first struck, millions of jobs were shed within weeks and unemployment levels soared. Thankfully, the economy is in a very different place today, and right now, the labor market is stronger than it's been in years. Not only are jobs available, but workers also are so confident in their ability to pursue better jobs that they're quitting in droves.

In a recent survey, Fidelity found that 51% of workers are considering quitting a job or actually did. But 21% of people who quit a job and had a 401(k) plan there cashed out of that account when they left. And that's a big mistake.

Be careful with your 401(k)

Saving consistently in a 401(k) is an important step toward attaining financial security during retirement. But it's important to know what to do with that retirement account when you leave a job.

A person with a serious expression at a laptop.

Image source: Getty Images.

Because 401(k)s offer benefits like tax-free contributions and tax-deferred investment growth, there are strict rules regarding withdrawals. If you remove funds from a 401(k) plan prior to age 59 1/2, you'll generally face an early-withdrawal penalty equal to 10% of the sum you remove. You'll also have to pay taxes on your withdrawal, though to be fair, the same would apply to a withdrawal taken during retirement.

Now, let's get back to the 21% of people who cashed out their 401(k)s when they left their jobs. Chances are, many of those workers incurred huge penalties and a whopping tax liability -- or at least those who left a job before turning 59 1/2.

And that's precisely why you shouldn't cash out your retirement savings when you leave a job. Not only are you likely to incur penalties and taxes, but you'll also leave yourself in a position where you don't have enough money set aside for your senior years.

Once you retire, you can't plan to live on Social Security benefits alone. And so you'll need money in savings to supplement those benefits. Cashing out a 401(k) prematurely could therefore leave you with a financial shortfall later in life.

What to do with your 401(k) when you leave a job

If you're getting a new job, you have several options for your 401(k). First, you can leave it where it is. Second, you can roll it into your new 401(k), if you have a job lined up that offers one. Third, you can open an IRA and roll your 401(k) into that account. That way, you get complete control over your money.

If you're going to roll your old 401(k) into a new retirement plan, your best bet is really to do a direct rollover. That way, your money hits your new account and you're not responsible for making that transfer. If you do an indirect rollover, where you get a check for your 401(k) funds and have to deposit them yourself into a new retirement account, you could get stuck with a penalty if you don't complete that transfer on time (you only get 60 days).

No matter what you do with your 401(k), don't make the mistake of cashing it out when you leave a job. Doing so could result in a financial headache -- and a lack of money later in life.