Fixed window closing behaviour