(NonModalNonParentDialog): New class, without parent, i.e. can fall behind other windows. (NonModalDialog.OnClose): Check is dialog is in mainwindow.dialog dictionary before removing it.