What command to stop loop when push switch is let go?

I've just started discovering programming with arduino. Have done the first two tutorials in the starter kit. Now I thought I'd use the knowledge from those and am trying to program a sequence of LEDs to light up one at a time when a switch i pushed (to be used with midi-keyboard as a small light show on stage). The LEDs light up just as I want them but I'd like them to go out, or start over, when the key/push button is let go, or pushed again. As it is now the loop cycle is always finished before the lights go out. Is there a specific command that can do this or do I have to re-design the programming?

int switchState=0;
void setup(){
pinMode(3,OUTPUT);
pinMode(4,OUTPUT);
pinMode(5,OUTPUT);
pinMode(6,OUTPUT);
pinMode(7,OUTPUT);
pinMode(2,INPUT);
}
void loop(){
switchState = digitalRead(2);
if(switchState==HIGH) { // the button is pressed
digitalWrite(3, HIGH); //red LED
digitalWrite(4, LOW); //red LED
digitalWrite(5, LOW); //red LED
digitalWrite(6, LOW); //red LED
digitalWrite(7, LOW); //red LED

delay(250); //  wait for a quarter second

digitalWrite(3, HIGH); //red LED
digitalWrite(4, HIGH); //red LED
digitalWrite(5, LOW); //red LED
digitalWrite(6, LOW); //red LED
digitalWrite(7, LOW); //red LED

delay(250); //  wait for a quarter second

digitalWrite(3, HIGH); //red LED
digitalWrite(4, HIGH); //red LED
digitalWrite(5, HIGH); //red LED
digitalWrite(6, LOW); //red LED
digitalWrite(7, LOW); //red LED

delay(250); //  wait for a quarter second

digitalWrite(3, HIGH); //red LED
digitalWrite(4, HIGH); //red LED
digitalWrite(5, HIGH); //red LED
digitalWrite(6, HIGH); //red LED
digitalWrite(7, LOW); //red LED

delay(250); //  wait for a quarter second

digitalWrite(3, HIGH); //red LED
digitalWrite(4, HIGH); //red LED
digitalWrite(5, HIGH); //red LED
digitalWrite(6, HIGH); //red LED
digitalWrite(7, HIGH); //red LED

delay(500); //  wait for a quarter second
}
else {  // the button is not pressed
digitalWrite(3, LOW); //red LED
digitalWrite(4, LOW); //red LED
digitalWrite(5, LOW); //red LED
digitalWrite(6, LOW); //red LED
digitalWrite(7, LOW); //red LED
}
} // go back to the beginning of the loop

Stop loop() as in when switch is pressed again, nothing happens?

while ( 1 ); // this is an endless loop with no escape

while ( digitalRead( 2 ) == LOW ); // this loop escapes when switch goes HIGH

In the meantime, your IDE has AutoFormat in the Tools menu. It indents code that can compile.
And there is something called array that you should learn.

You should not think of the problem as how to stop loop() but rather as how to get some activity to stop while loop() continues.

A common way to do that is to put the activity into a function which only works when a variable is true. For example

boolean makeStuffRun  = true;

void setup() {
}

void loop() {
   doSomethingInteresting();
   makeStuffRun = false;
}

void doSomethingInteresting() {
   if (makeStuffRun == false) {
        return;
   }
   // do all the interesting bits

}

...R

And if you don't want to wait why the delay completes ( there is no way to "see" anything while your in delay()) then you must look at the blink without delay example and never here after use delay().

Look at FSM (Finite State Machine) in the playground and debounceing buttons also in the playground.

Mark

Thanks for your replies! I only understand a fraction of what you wrote, so now I´ve got some homework to do.