Esp 32 ap keep turning off

You are not very clear! Pretend you are talking to someone who has never heard of Arduino

How do you connect the phone to the app - by wires, blue tooth, wifi ??
The App looks very complex - you might need to start with something simple that illustrates the problem

Do you mean when you switch your phone off (with the power button) the ESP32 also powers down?
of ==Off
ap ==App