Fix window closing