Sequential tail lights controlled with IR remote

Is there a way to break the while loop by pressing another button. Because if there is I don't know how to set that up. A counter variable won't work, since it will just go until the variable reaches a certain number. I need the loop to stop exactly when I say with the push of a button.