The way it's usually done is shown below. Driving the mosfet gate directly from the GPIO is not a good idea because when the MCU's power goes down, the GPIO will drop to ground, and that will turn on the mosfet. So you add the extra NPN, which requires the GPIO to go output high to turn on the mosfet. Then the two diodes let the push button also serve as an input for some other purpose. If pressed a long time, that could be the signal to shut down.