I think you should use a function, but another way would to be to have a boolean variable that is checked at the start of every loop that you would set to false when you want to break the loop. But that would require n-1 variables for n nested loops.
Sorry, I noticed I never gave credit for this answer. Here is my long overdue thank you!