If you have a backup of your *.livecode, open it while you are stuck in the loop. It will tell you "A stack with the same name as the one you are trying to load is already open." and give you the option to save the stack that is stuck in a loop. Then you can reopen it and fix the loop.
If you only have one copy of your *.livecode you are doing it wrong IMO
