Changed the conditions of stopping the app