for this purpose there exists an extension you might want to use...
alternatively you will have to keep the screen on to keep the application alive...
one method to do this is to use the KeepScreenOn method from the tools extension App Inventor Extensions: Tools | Pura Vida Apps but this will drain the battery faster...