Boe- Bot for Arduino- program malfunctioning

Hello, I’m a newbie to robotics. This is the first Arduino project I’ve done. Right now, I’m working on a basic program that tells the two servos on my robot to go forward for 2 seconds, turn left in place for 1 second, turn right in place for 1 second, and then go backward for 2 seconds. I will attach the code below.
When I test the program while it’s propped up on a small box (so it won’t drive off the table), it works fine. The wheels both go forward, then turn one way, turn the other way, and go backwards. I also have a tone at the beginning (under void setup) so I know when the program starts. The problem is when I unplug the robot from the programming cord ( usb to serial). The wheels go forward for 1.5 to 2 seconds, and then it plays the start-up tone and the wheels go forward again. This cycle, forward and beep, continues indefinitely, even though it’s under the setup function.
I checked the batteries to see if it was a brownout problem, and they’re all fine. Hopefully somebody here can give me some suggestions as to what the problem might be.

// Robotics with the BOE Shield - ForwardLeftRightBackward
// Move forward, left, right, then backward for testing and tuning.

#include <Servo.h> // Include servo library

Servo servoLeft; // Declare left and right servos
Servo servoRight;

void setup() // Built-in initialization block
{
tone(4, 3000, 1000); // Play tone for 1 second
delay(1000); // Delay to finish tone

tone(4, 4500, 3000);
delay(3000);

servoLeft.attach(13); // Attach left signal to pin 13
servoRight.attach(12); // Attach right signal to pin 12

// Full speed forward
servoLeft.writeMicroseconds(1700); // Left wheel counterclockwise
servoRight.writeMicroseconds(1300); // Right wheel clockwise
delay(2000); // …for 2 seconds

// Turn left in place
servoLeft.writeMicroseconds(1300); // Left wheel clockwise
servoRight.writeMicroseconds(1300); // Right wheel clockwise
delay(1000); // …for 0.6 seconds

// Turn right in place
servoLeft.writeMicroseconds(1700); // Left wheel counterclockwise
servoRight.writeMicroseconds(1700); // Right wheel counterclockwise
delay(1000); // …for 0.6 seconds

// Full speed backward
servoLeft.writeMicroseconds(1300); // Left wheel clockwise
servoRight.writeMicroseconds(1700); // Right wheel counterclockwise
delay(2000); // …for 2 seconds

servoLeft.detach(); // Stop sending servo signals
servoRight.detach();
}

void loop() // Main loop auto-repeats
{ // Empty, nothing needs repeating
}

[/quote]