Fixing an issue when a maximized window is closed.