Create a local string variable (i.e. Timeout) then after each Wait add the following:
Set Timeout to %device%
IF (Timeout = 'timeout') Exit Rule
Org post talking about this technique [2.2.4.158 C7] Need a way to detect/act on wait timeouts - #3 by bravenel