brake function can only run for 50ms

added a second condition for the braking while loop so that it will exit
after 50ms so that we do not loose control of the vehicle