If you use an H-bridge to provide the pwm you can reverse the supply voltage on the motor pins so that it acts as a brake. An other solution might be to switch a resistor or a zener / TVS diode between the pins so that the voltage rises and energy is dissipated faster (but watch out for the breakdown voltage of the driving mosfet/chip/whatever) - this second option has its caveats and is typically slower.