You can't perfectly time your retirement to match the S&P 500 average. That's the reason your portfolio shifts to bonds as you get older. It's the reason everyone quotes 7 & 8% as reasonable long-term returns for your retirement portfolio.
Some would end up lower but some would end up higher.
Nothing is guaranteed, but neither is a job.