Fixed problem with app not exiting properly on close