use e.cancel to stop the window closing