Fix bug where we we not properly dismissing dialogs