Prevent Lithium battery discharge until USB/Charging voltage is present (for the first time)
This is the type of thing I have done in the past. It might not be exactly what you are looking for. When USB VBUS goes high, capacitive coupling turns on M2 which turns on M1. Once M1 comes on, R2 pulls up the gate of M2, keeping it on.

A GPIO would drive the gate of M3 high when you want to cut power to the system. This will obviously cut power to the processor itself. It is kind of like "suicide" for the processor.

Some tweaking might be required. Circuits like this can be finicky, but I have gone to production with things like this.







simulate this circuit &ndash; Schematic created using CircuitLab