The motor windings are inductors, so store electrical current in the form of a magnetic field.
It takes some amount of time for them to "charge up", usually very quickly in a motor.
Once that energy is in the form of a magnetic field, where will it go if the power is suddenly disconnected?
The interesting thing about inductors is, that they always take some amount of time to charge, but want to discharge instantly (opposite characteristic) if you let them.
What that means is, disconnecting a charged inductor will produce whatever voltage is necessary to keep the same current flowing. This voltage can be hundreds, thousands, even tens of thousands of volts.
Now energy cannot be created nor destroyed, so when this voltage goes up, the current goes down such that the net power is the same, minus losses.
So when a transistor (with a definite voltage limit) is powering this and opened, then that current will almost instantly manifest as a very high voltage (and low current) across the (now open) transistor, thus destroying it.
D1-D8 ensure that this voltage is instead "clamped" to the power supply, which usually has a beefy capacitance. Being regulating, it will momentarily reduce it's output to maintain accurate regulation (because it sees that it doesn't need to supply much power.)