You’ll pay massive penalties on that, another option is options (heh) but I’m not finance-literate enough to know how to pull it off.
You can just reallocate away from an index fund.
I’ve made my peace with the “massive penalties”. I benefited from employer match in the past. I want the money now, not when I retire.
You could just buy deep out of money SP500 puts expiring in 1+ year. That way you would be "insured" against the bubble popping.
The thing is, every dollar you spend on insurance is a dollar (and its interest) you lose. Furthermore, we don't know when it will pop. 1 year? 5 years?
The more reasonable solution is probably gradually reduce exposure to US markets by selling SP500 shares and turning to Europe and emerging markets ETFs. No need to cash out 401k.
Only penalties if you withdraw from 401k. Most 401k plans have some kind of moneymarket, bond fund, or similar