Moved close button event onto the window