No matter what threshold value you are using, there is nothing that tell the motors to stop after they are started...
How are the motors connected? I see a pwm pin and an enable pin. There should be a direction pin (or 2 pins sometimes...). If you set the enable pin LOW, the motors should be disconected, but free wheel spinning, that will keep the robot running off the table. You need to brake the motors or switch direction from forward to reverse. There you need the direction pin(s). If you are using 2 direction pins, set them both HIGH or LOW and the motors will brake. If you use only one direction pin, set the direction pin LOW and the pwm=0 and the motors will brake.
Perhaps your enable pin is actually a direction pin? In this case, if you set the pwm pin to 255 (HIGH) and the enable pin to LOW, the motor will spin in one direction (forward). If you set the pwm pin to 0 (LOW) and the enable pin to HIGH, the motor will spin in the other direction (reverse). If BOTH pins are set either HIGH or LOW the motor will be braked.