Thanks Phillipe
That idea works OK so far.

But if the script already has subroutines, this method won't quit from inside the subroutine. I think I will have to set a global flag and keep checking it.

Thanks for your help
Stuart