application is closing correctly now