Fix for clicking close button and then popping up dialog again