checking which window closes