simulate this circuit – Schematic created using CircuitLab
Figure 1. OP's schematic redrawn with switch replacing the transistor and normal current flow from top to bottom (as is standard in schematics).
Now it should be clear that when SW1 opens no current can flow into the battery positive as no "return" current can flow from the battery negative.
Instead, think of the inductance as trying to maintain the current in the direction it was flowing. With the diode present it will circulate from the bottom of the motor back to the top until it decays to zero due to the power loss in the diode and the motor winding resistance.
Your concern is valid if regenerative braking is required. In this case the generated power is passed back to the battery (or power supply). The usual way of dealing with this in variable speed drives or servo drives is to monitor the DC bus voltage and if it exceeds a certain voltage to switch in a load resistor to burn off some power. But that's a different question ...