Not that easy, you cant say what process needs to be kept alive, you need to integrate that into each application itself. So most likely in your use case its just easier to keep your phone in charger, or have external battery charger connected. (Or keep display on).