break after x second()

Here's a loop that will break after 9 seconds:

for (unsigned long starttime = millis(); millis() - starttime < 9000; ) {

}