Fix for dialogs displaying after they are destroyed