Fix bug when closing already destroyed dialog