It seems it is waiting for the stepper motor to go through all of its steps before it executes any other code.
That's going to depend on how the code is written.
One way would be to command the stepper to move 1000 steps then check if the limit has been reached. A better way would be to command the stepper to move 1 step, check if the limit has been reached, stop moving if has and to do that 1000 times, or at least to use that principle.