If the stack is emptied, stop the motion
updated version