Alternative take on the parent comment: take on some risk as a consultant to avoid the risk of getting laid off, and do it well in advance of retirement.
Startups are high-risk, high-reward ventures which make less sense to attempt as you age. It's normally a good idea to start moving your assets into fixed income and other low risk investments as you approach retirement, the same risk aversion applies to your income source(s).
Making the shift to consulting, if done properly, actually lowers your income risk because you can't lose your entire income in one go. If you have 3-4 regular clients, the most any one of them can do is force you to take a partial pay hit.
That's why it's a good idea to consider this path and start laying foundations that could make it possible long before you turn 50. Even though many HN users seem to misunderstand it, this isn't a novel idea by any means.