Added exception handling for running a dialog in a modal state.
Application will now close even when a modal dialog is open.