adding event listener, so the window can now be closed