Dragging button problem

I’m using this crank to scroll thru images (that part works greatttt!!!)

when you hold down the left mouse button and drag, the crank rotates . . .
but you can move the mouse all around (and off the knob) and still rotate.

How can get the crank to stop when the mouse pointer is off of the knob?