Ensure onWindowClosed is called when dialog/window is closed