Fixing window closing