Many Americans plan to work into their 60s or even beyond to save for their golden years and avoid having an overly lengthy retirement. An alarming percentage, however, ultimately don't get that choice.

More than half of older Americans are pushed out of long-term, otherwise stable jobs earlier than they'd prefer, according to data from ProPublica and the Urban Institute. Specifically, the two groups began studying working Americans back in 1992 from the time they turned 50 through the remainder of their careers. What they found was that as of 2016, 56% of the workers they studied were either laid off at least once between turning 50 and retiring, or pushed out of their jobs in some shape or form. Worse yet, only 10% of those workers managed to earn as much as they did before their layoff or forced exit.

If you're an older worker whose job seems stable, know that, unfortunately, you might find yourself unemployed as a result of age discrimination. Here's how to protect yourself in the face of that possibility.

Older man at computer

IMAGE SOURCE: GETTY IMAGES.

1. Build a nest egg earlier on in your career

Many people assume they'll have plenty of time to catch up on retirement savings if they don't manage to save all that well during their 20s, 30s, and 40s. And to some degree, that makes sense. Many workers find that once their 50s roll around, they no longer have to bear the cost of supporting children who live at home. Throw in the fact that many folks earn more in their 50s than they do earlier on in their careers, and it stands to reason that it's a good time to get serious about retirement.

The problem with that plan, however, is that you never know whether your career will get cut short during your 50s, and if that happens, you might find yourself in a financially troubling spot. A better bet, therefore, is to start saving for retirement from a much earlier age, and ramp up your savings rate as your salary increases from year to year (which it hopefully will). Or, save a respectable amount steadily over time, and invest it wisely to grow your nest egg.

Contributing $500 a month to a retirement plan over a 30-year period, for example, will leave you with $567,000 if your investments generate an average annual 7% return during that time. This means that if you start saving at age 25 and find yourself out of a job at 55, you'll have a decent cushion to fall back on, even if you're then forced to take a lower-paying job for the remainder of your career that doesn't allow for much additional savings.

2. Document discriminatory behavior on your employer's behalf

Most companies employ workers on an at-will basis, which means an employer can technically let you go for any reason provided it's not based on factors such as gender, race, or age. If your company tries to oust you simply because you're older than its average employee, documenting every instance in which you're treated poorly or unfairly could help make the case for a lawsuit in the event that you're terminated because of your age. That means any time a manager makes a reference to your gray hair or grandparent status, you should log the date, time, and circumstances of the incident. The same holds true if you notice a pattern of being stripped of responsibility as you age despite the fact that your skills are only progressing.

3. Start a side business

One final way to protect yourself in the face of ageism is to establish a solid side business on top of your regular job. Doing so will no doubt require a major effort on your part, but if you push yourself to make it happen, you'll benefit in a couple of ways. First, you'll have extra income with which to fund your retirement savings, thereby making an earlier-than-planned exit from your main career less catastrophic. Just as importantly, you'll have work to fall back on if you lose your job and it takes a long time to find another one (or, worse yet, you don't manage to find another one at all).

Though it's illegal to discriminate against employees because of their age, unfortunately, many companies ultimately get away with it. If you want to reduce your chances of struggling financially in retirement because you're forced to enter that phase sooner than planned, follow the above steps. A little vigilance on your part could go a long way if your employer does indeed try to force you out of a job at a precarious stage of your life.

The Motley Fool has a disclosure policy.