Added check to handle close and cancel buttons in dialogs