Persistent is to continue loop, you could do the same with a while loop and exit condition.
Code:
HotKeySet("{ESC}","stop")
$running = False
Func stop()
$running = False
EndFunc
Func mainLoop()
$running = True
While $running
;Your program logic here
ToolTip("script running " & @HOUR & ":" &@MIN & ":" &@SEC,0,0)
Sleep(5);add delay to prevent high CPU ussage
WEnd
EndFunc
mainLoop()