Maybe you can give me a way to stop these loops? Maybe a way as example to my code part?
If you will not post all of your code then it is difficult to give specific advice but maybe something like this
set OKtoRun variable true
start of loop()
if OKtoRun is true
outer for loop
inner for loop
do motor stuff here
end of inner loop
end of outer loop
set OKtoRun variable false
end of if
other code goes here
end of loop()