Running the program for a specific amount of time

void setup() {
  // put your setup code here, to run once:
}

void loop() {
  // put your main code here, to run repeatedly:
  if (millis() >= 120000UL) { // Arduino has been running 2 minutes from power up.
    for ( ; ; ) { // Never exits this loop.
    }
  }
}