Arduino locks up when used with P-channel MOSFET

That circuit is flawed, the GPIO pin is held LOW when the chip is powered down by the protection diode, which turns on the MOSFET, powers up the chip, floats the GPIO pin and lets the MOSFET gate discharge through R2,
turning off the MOSFET, powers down the chip, the GPIO pin is clamped low by the protection diode, the MOSFET turns on, etc, etc.

No auto-switch circuit can be made from a single active device like this due to the protection diodes
phantom-powering the chip.

You need at least two active devices to implement such a switch, or a reed-relay.