Brushed DC motor braking with speed controller
It is never a good idea to short motor terminals. For a permanent-magnet DC motor with a commutator, you need to disconnect the armature from the power source connect a resistor across the armature terminals. Rather than using just a fixed resistor, better braking performance will be provided by a PWM braking circuit that will regulate the braking current.

The ohmic value of the resistor should be chosen to draw no more than 150 percent of the rated armature current at the rated armature voltage. The power rating needs to be based on the motor plus load inertia, the load torque and the duty cycle. The total dissipated energy in the braking resistor for a braking cycle will be the energy stored in the rotating mass minus the energy dissipated in the load and in the motor losses.