How should I close or minimize App during BackgroundTask.beforeExit is running? If I just call App.exitApp code in BackgroundTask.beforeExit will not be completed
In general you should never need to run
exitApp because the user should have full control over the lifecycle of your app.
However, the way to use
beforeExit is to make sure you call it if you are still running a long-running task and the app will be suspended: https://capacitorjs.com/docs/apis/background-task#example
I call exitApp when user press backbutton on app home page.
As it says in docs https://capacitorjs.com/docs/apis/app#exitapp
Force exit the app. This should only be used in conjunction with the backButton handler for Android to exit the app when navigation is complete.
What should I use instead?