Create dialogs in MainWin on the heap, rather than on the stack.
This avoids crashes when MainWin is destroyed while a dialog is
open (in which case a double free would happen).
Set the WA_DeleteOnClose attribute on affected dialogs so they will
be deleted upon close, rather than hanging around in memory until
shutdown.