Yes, Vektorboson reads this thread, and he answers, too!
Since 1.85 there is the command dialog which determines whether a dialog is opened or not. So if you press ESCAPE dialog will turn to false.
So in your script where you create the dialog you execute also another script that monitors whether the dialog was closed:
_ok = createDialog "MyDialog"
[] exec "monitorDialog.sqs"
And here is "monitorDialog.sqs"
@!dialog
camdestroy _camera
_camera cameraEffect ["terminate", "back"]
...
...
This should solve your problems,
greetings,
Vektorboson