serial while loop break

i have setup my arduino with rgbs and created a little program to make them flash but how do i stop the loop with a serial command?

int red = 12;
int blue = 11;
int green = 10;
int inByte = 0;
int x = 0;

void setup(){
pinMode(red, OUTPUT);
pinMode(blue, OUTPUT);
pinMode(green, OUTPUT);
Serial.begin(9600);
Serial.print("Ready");
}

void loop(){
if (Serial.available() > 0) {
inByte = Serial.read();
}
if (inByte == '1 2`'){
digitalWrite(red, HIGH);
}
else if (inByte == '2'){
digitalWrite(blue, HIGH);
}
else if (inByte == '3'){
digitalWrite(green, HIGH);
}

else if (inByte == '0'){
digitalWrite(red, LOW);
digitalWrite(blue, LOW);
digitalWrite(green, LOW);
}
else if (inByte == '4'){
while(true){
digitalWrite(red, HIGH);
delay(100);
digitalWrite(red, LOW);
delay(100);
digitalWrite(green, HIGH);
delay(100);
digitalWrite(green, LOW);
delay(100);
digitalWrite(blue, HIGH);
delay(100);
digitalWrite(blue, LOW);
delay(100);
// need to break by serial command here
// something like if (Serial.read() ==~ 4){
break;}//
}
}
}

You could break out on the first key by testing for Serial.available()>0...

-br

Edit: added ()

just realized i made a mistake should be if (inByte == '1'){ digitalWrite(red, HIGH);}
but this still doesnt fix my problem

thanks the serial.available works perfect

In your program inByte is an int (a number) and you are comparing it with a char (a character). Ask yourself, will they ever match ?

Either change inChar to a char or compare int inChar to the ASCII value of what you are receiving ( 1 = 49, 2 = 50 etc). Try printing what you are receiving to see what is going on.

In your program inByte is an int (a number) and you are comparing it with a char (a character). Ask yourself, will they ever match ?

If I ask myself the question, will it stop working for me?

OP, need to see your code as it is now.
Please use code tags.