When an old colleague of mine got laid off last year at age 58, he knew he would be facing a tough battle. It's illegal to not hire a job candidate based on their age. But the reality is that many employers are hesitant to extend offers to older workers for fear that they'll put in the time to train them only to then have them retire in a handful of years.

The problem my former colleague and friend faced was that he'd gotten a fairly late start to retirement savings. And as such, he couldn't afford to just end his career at 58.

A person at a laptop raising their arms as if annoyed.

Image source: Getty Images.

In the end, he spent almost a full year going on interviews before finding a suitable replacement role. And while he's happy to be gainfully employed again, he knows all too well that if cuts were to become necessary at his place of work, he'd risk landing on the chopping block again due to his age.

If you're someone who's over age 50 and was recently laid off, you may be frustrated by how difficult it is to find a job. And you may be inclined to resign yourself to an early retirement.

But retiring in your 50s when that wasn't your plan could put you at risk of depleting your retirement nest egg in your lifetime. So rather than run that risk, consider these moves first.

1. Do a career pivot

If you held a senior-level position before getting laid off, you unfortunately might struggle to find a similar role if you're perceived to be nearing retirement. And you might also struggle to secure a lower-level role in your industry because employers might assume you don't want a job of that nature.

Rather than retire in that situation, consider a career shift. Employers may be more open to welcoming you into a lower-level role if you explain that you're expressly looking to spend the next decade in a new field you're more passionate about.

Of course, going this route could mean taking a pay cut. And that's not ideal. But you're better off earning less money and perhaps cutting back on spending than accessing your retirement savings early, risking a penalty, and blowing through that cash at a younger age than you wanted to.

2. Consult or start your own business

If you're struggling to find a company that will hire you to do the work you were doing prior to getting laid off, consider continuing that work without the support of a company. Start a business yourself, or simply become a freelance consultant. You may find that if you reach out to contacts you used to work with, they'll be more than happy to hire you independently if you always did a good job for them.

3. Moonlight in the gig economy

There are certain gigs you may be able to do without specific qualifications -- things like driving for a ride-hailing service or grocery delivery. These may not be the highest-paying or most desirable jobs. But if you can put up with them for a few years rather than retire early, you can potentially preserve more of your nest egg and avoid financial troubles down the line.

On the plus side, joining the gig economy often allows you to set your own hours and perhaps maintain a work schedule that's not so demanding. And it could actually serve as a nice transition into retirement without retiring in full.

Getting laid off later in life can constitute a major blow. But before you retire early, consider these alternatives to avoid the financial hit that could result if you were to tap your nest egg years ahead of schedule.