Fix issue where callback doesn't get invoked when dialog is closed.