Scoping error caused the Unsaved Changes dialog not to be shown when closing the main window