ensure application is closed