Add Pre-Close Callback/Confirm Close

Add the ability to specify a callback that is called before actually
closing the dialog to allow the close to be canceled.  For example, if
the dialog contains some sort of editing work and the user accidently
presses escape the callback can confirm with the user that they want to
exit and return false to prevent the dialog from being closed.