All AC electric motors can operate in four quadrants, i.e. the torque can be forwards or backwards when the motion is forwards or backwards (4 combinations). When operating, zero torque is a balance; the motor controller can smoothly change the phase of the applied rotating magnetic field relative to the field from back EMF. It's a bit tricky explaining it if you're not familiar with AC motors.
So the motor controller has complete control of the torque, in magnitude and sign (direction). Thus, this is a control issue. The motor controller will be aware of the present torque, and it will have a torque set point (the torque that it's aiming for). It will probably use a PI control algorithm (Proportional and Integral components). This is needed to achieve the desired torque quickly and accurately, without excessive overshoot and continual corrections.
The integral part of the control is necessary among other reasons for preventing a small offset between the set and actual torque. But there is a thing called integral windup that can occur if you don't implement the integral control properly. Basically, when you need to apply a large change, as you would if the brake is pressed quickly, or if the OPD pedal is reduced quickly, then the integral term can become quite large. Without some limit to this term, you end up with overshoot that persists as the large integrsl term slowly reduces. In this situation, the result is creeping backwards for a time, or if the integral wind-up is worse, you get significant reverse torque.