Fixed a resource leak of modal dialogs