Regenerative Braking circuit
Summary:
If you use a position encoder wheel you can manage the commutation of generation and regeneration according to the difference between supply and load for each phase of the motor.
The H bridge allows you control polarity of drive voltage to or from the battery depending on which is higher and demand of acceleration or braking.

Two methods are show below.