Dear Sophie: How can I protect my H-1B and green card if I am laid off?

I’ve been hearing that you can lose your H-1B status if you are laid off. Is there any way I can protect my immigration status while making a bold job move?