Fix application exiting