“Win the lottery” doesn’t really work in tech. So many mid career engineers are deca-millionaires with 15-20 years of grants and refreshers. They’re working because they enjoy the work.
Even at “regular” companies that don’t have hockey stick stock graphs, lots of the senior engineering staff are quite well off by their 40s. One of my division leads sold his last startup for 10s of millions of dollars. He still send emails late on Friday nights.