Ending a programme w KeyboardStroke

"while (1)" and "while(2)" are both equivalent infinite loops, because both 1 and 2 are true.

if (Serial.available ())
{
  while (1);
}

will stop your sketch running.