Millions of American workers dream of a great retirement after they finish their careers.

They have a great job, they contribute to their employer-sponsored 401(k) plan, they expect Social Security to help supplement their retirement income, but then a shock comes.

Unfortunately, a large number of Americans make a major mistake when they face some of life's misfortunes, such as getting laid off or leaving a job because an employment situation simply doesn't work out for whatever reason.

Related: AARP sounds alarm on big Medicare, Social Security problem

AARP, the nonprofit advocacy organization for Americans over 50 years old, sends a major warning message to people in this exact situation.

"Each month, more than 5 million private-sector employees quit, get laid off or otherwise leave a job, according to federal labor data," AARP reported. "Among those with 401(k) plans, a recent study found, about 41 percent drain those retirement accounts upon a job separation."

In my many years of reporting and writing about 401(k)s (and other personal finance concerns Americans face), I am urging you to take a strong look at this and realize what a huge mistake this is.

AARP warns people not to make big retirement mistake

Workers who leave a job often treat the balance in their retirement plan as a sudden windfall, and that perception makes them far more likely to cash it out.

That is the exact formula to miss out on opportunity cost. For one, there are penalties.

"Cashing out a retirement plan before you reach age 59-and-a-half typically means paying a 10 percent tax penalty for early withdrawal — on top of any regular income taxes you owe on the money," AARP explained.

More on personal finance:

More importantly, it is easily argued, making this mistake causes one to miss out on growing investments.

"Suppose you’re 40 when you switch jobs. The $20,000 in your 'old' 401(k), if kept intact, would grow to more than $108,000 by the time you hit 65, assuming an average annual return of 7 percent," AARP appropriately writes. "The S&P 500 has averaged a 7.2 percent return over the past 30 years, adjusted for inflation."

That's undeniably a big investment for one's future retirement plans.

AARP: Don't risk running short in retirement

That quick boost of cash can leave a lasting dent in your future savings, undermining your ability to sustain a comfortable lifestyle in retirement or manage rising health care costs as you get older.

“Cashing out early may have negative implications, the most severe of which could be superannuation or outliving your retirement funds,” says Devin Carroll, owner of Carroll Advisory Group, a retirement planning firm based in Texarkana, Texas.

“Even if you don’t get to that point, you may still jeopardize your ability to lead the lifestyle you planned for in retirement.”

AARP warns Americans about financial mistakes on 401(k)s and relying on Social Security when planning for retirement.

Shutterstock

Ways to handle an old 401(k) when you leave a job

Here are some very important strategies to explore as you avoid making major mistakes:

Ways to handle an old 401(k) when you leave a job

(Source:AARP)

Roll it into an IRA

(Source:AARP)

Roll it into your new employer’s 401(k)

(Source:AARP)

Related: AARP sounds alarm for American workers on 401(k)s, IRAs