Improvements in app not closing bug