I'm not sure exactly what you want to achieve. Whether you want the script to quit because of a vast array of actions of just one? Or, how complicated the event that causes the script to quit will be? Or, whether you want this to just cover quitting a cutscene?
I'm going to assume it's to force quit a cutscene and I'm also making the assumption it's a simple event, you could create another smaller script, "scriptend.sqs", for example and run it from the player's init field. And, in it write something like:
; loop begins
#Loop
; wait 0.01 seconds
~0.01
; check if unit is still alive
? not alive unitname : GoTo "Next"
; reread code from loop
GoTo "Loop"
; continue reading code from next
#Next
; terminate the camera to stop cutscene
_cameraname cameraeffect ["terminate", "back"]
camdestroy _cameraname
; exit script
Exit
I'm not sure if that's any help, or if that's anything like what you wanted, though...