I wonder if we should close the dialog before calling the callback.  If the callback had a visual side effect, it would be obscured.

Actually, if the callback threw an error, the dialog would not be dismissed and the user would be stuck.

So please change to close first here and below.