My understanding that Android apps don’t “exit” themselves.
An app is closed by the Android O/S, either in response to a user action such as touching the back-arrow, or by the O/S closing the app to reclaim resources.
The app receives an event such as onStop() or onDestroy() so that it can do cleanup like saving data or releasing resources.