The best you can do is set the target position equal to the current position. If the system has too much inertia to stop, you may want to move the limit switches in advance of the physical limit just to be sure.
I have a follow up question about integrating an encoder:
How can I use an encoder to control the stepper position instead of the controller's internal logic?
I'm using a ENC1000 to read a linear quadrature encoder. I have several positions along the travel where I activate functions unrelated to the stepper control so I'd like to have everything in the same reference frame (the encoder's) to simplify things.
My guess would be to add a check in the encoder's onPositionChange handler that verifies where the motor is relative to the target position and sets it's velocity accordingly, but adding more stuff might slow down the callback.
I could also use step mode, fiddle around to get the rescale factor correct and use the limit switch to zero the position on both so they match if the first option doesn't work.