I did some workaround on this behavior by adding an event listener on the dialog box via JS. This way the callback will be triggered.
window.addEventListener("beforeunload", function (e) {
sketchup.focus_dialog()
}, false);
@dlg.add_action_callback('focus_dialog') do |ac|
@dlg.bring_to_front
end