Using a voltage supervisor IC to protect a Li-Ion battery from undervoltage >2.8V?
This is the basic idea. If you push and hold the button, the regulator will be forcibly enabled. Then the output of the regulator will come up and pull up the enable pin so that the regulator stays on when the user releases the button.

The GPIO pin must not go high. When the time comes to shut down the regulator, you can assert the GPIO pin high, and it should disable the regulator. You may need to add a diode and capacitor to the base of the regulator to make sure it is driven low long enough to fully turn off the regulator. I didn't show those. I can add them if you want.







simulate this circuit &ndash; Schematic created using CircuitLab

This is just one way to do it. Not shown is the sense circuit used by the processor to monitor battery voltage. That may need to be controlled by a switch also, so that it doesn't drain the battery when the regulator is disabled.