Below is the script I am using to detect if my application is being closed. If it is closed the application will restart again. The application should run in the background