"Despite that, it can still act as a generator when slowing down, as permanent-magnet motors do in electric cars."
I wonder how this works: The motor requires a control system anticipating how it moves to keep it running. But when used as a dynamo, it's the inverse, something else makes it rotate. Does the control system go to a different mode here?
So assuming we're talking about a synchronous machine aka permanent magnet AC motor, the control of whether the motor acts as a generator or motor is inherent in the physics of the machine. Inside the motor are polyphase AC windings which with the help of an inverter create a rotating electromagnetic field (usually the stator). The rotor position is sensed, and thus the control system can vary the angle between the electromagnetic field and magnets in the rotor. This angle is called the torque angle, and if it it is leading the rotor ("pulling it along") then the machine produces torque. If some external force accelerates the rotor (or if the control changes the phase angle) then the rotor is lagging ("pushing against the magnetic field") then the torque is converted into output current.
Practically this means that a synchronous motor spinning at a particular speed (again set by the AC inverter) will consume power if it is under load and produce electric power if externally driven.
The AC inverter is designed such that power can flow in either direction. When supplying power to the motor it acts as an inverter, when the motor is supplying power it acts as a rectifier. So basically the control just needs to change the phase angle to control whether the motor produces torque or acts as a generator.
I assume that the operation of the switched reluctance motor covered in the article is similar.