You can use processing within the ATTENTION ON-unit to terminate potentially endless looping in a program.
Control is given to an ATTENTION ON-unit when polling instructions recognize that an interrupt has occurred. Normal return from the ON-unit is to the statement following the polling code.