fix window closing