Consulting is always a way to go? Having a track record of success over a long period of time makes it easier for businesses to hire you. To be fair, around the 45 ish age, I would expect most folks to have evolved to a senior+ where it should be more about architecting systems and figuring out how to solve business problems then just executing on code.
I saw plenty of those folks 50+ at FANG-ish companies whilst working in the Bay but ofc that's just an anecdote.