You need a global variable. Put something like this at the beginning of your flash.sqs script:
stopflash=false
and then somewhere in the script (I assume you have a loop in there):
?stopflash:exit
In the deactivation box of the trigger put:
stopflash=true