fix issue where the app was not exiting properly.