Dear god, not the nested for loops...
You need an extra condition in your for loop to check if it's been 10 minutes since you started.
The first thing to do, it is set a variable to hold the time you started:
unsigned long started = millis();
Then you need to update your for loop's condition to check if it's been less than the interval:
for (initialStuff; ( (condition1) && (millis() - started <= someInterval)) ; incrementStuff)
That will tell the for loop to continue while both condition 1 is true, and it's been less than the someInterval value.