Detecting if script is io bound

Is it possible to detect if there is a problem in the script and it is stuck in a loop?

For example, during the following snippet, I can’t seem to terminate the script?:

repeat

until forever;

Or, a way to introduce a time slice to allow the script to terminate in the above condition.

Thanks,
Ken D.

There are low level events that trigger for pretty much any operation, OnLine it’s called iirc.