The usual strategy is to connect the switch in series with the power input and also bypass it with a transistor. The transistor is controlled by the MCU.
When the switch is closed the MCU receives power. The first thing the MCU does is configure to power control pin as an output and use it to make the transistor conduct, keeping the power connected. To shut it down, the transistor is turned off, removing all power until the switch is pressed again.
With suitable voltage protection, the switch can also be used as a logic or analog input.
Brian.