IR Remote - Stop motor in progress

Non-blocking code and a state machine are two different things which are often used together.

if you want a responsive program then you need to check the IR input between each step and you should not use a blocking WHILE loop. In most cases WHILE can be replaced with IF and then allow loop() to take care of the repetition.

Have a look at how the code is organized in a non-blocking way in Several Things at a Time and in Planning and Implementing a Program

...R

Stepper Motor Basics
Simple Stepper Code