Cut off a circuit whitest charging a battery
There are plugs and sockets that have contacts that "make" or "break" as the plug is inserted. Use one that when you insert the charger plug, it closes the circuit to the battery and disconnects the battery from the rest of the electronics, and when you remove the plug, the battery is reconnected to the electronics.