Starting an Arduino with a button - shutting down with software

Will this work
I need a little help from you guys.
Im making a project with an Arduino or ESP module.
I need to turn it on by a press on a button, and to power down by software.
I have made a schematics, and Im going to make a test when I get the parts. In the meantime Im going to make my pcb. But Im not sure about the schematics.
The idea is:
• When the pushbutton is pressed it opens the mosfet that powers the voltage regulator and
gives 3.3V to the micro.
• First thing the micro does is to switch pin 7 to high keeping the mosfet high.
• Now the Arduino should be running until pin 7 is set to low(AND the Pushbutton is NOT triggered)
Can anyone please help me to verify if the schematic is right. My concern is around the Mosfet. It looks wrong to me, but I cannot really tell why. Just a bad feeling.

You can't do this with a single transistor. Your circuit has the pFET on continuously when the button isn't pressed.

My preferred solution is to use a 74HC series set-reset flip-flop, permanently powered, one input triggered by a switch, the other from the Arduino pin. A pFet is driven from the active-low flip-flop output to power the Arduino.

2 NOR gates can be used to make such a flip-flop. 74HCxx series consume nanoamps only so you
don't have to worry about power drain (TTL chips would not do the job, note).

The reason a single device cannot do the job is that such a device inverts, which means when the Arduino pin
powers down the device input must go low, so its output must go high, turning it back on. Arduino pins are clamped to the supply rails by protection diodes so there's no way to avoid this.

peter844:
Can anyone please help me to verify if the schematic is right. My concern is around the Mosfet. It looks wrong to me, but I cannot really tell why. Just a bad feeling.

Capture.JPG
Your suspicion is correct, it is rubbish!

You need a NPN transistor or N-FET to turn on a P-FET. Sorry, no time at present to find the circuit for you; someone else may. MarkT suggests an HCMOS gate to replace the N-FET - that is actually quite clever; whether it is cheaper or more compact is not obvious.

Better idea: use a Pololu Power Switch, controlled either by switch or logic input.