Made the [X] button in the dialog handle correctly