Electric motors are great things, current flowing through coils of wire on the central shaft results in strong magnetic fields, which are attracted and repelled by permanent magnets around the outside of the motor, thus producing rotational motion. If you then stop applying power to the motor, the spinning coils interact with the permanent magnets to generate a current in the reverse direction while slowing the motor down a little. Apply a load that wants to draw lots of current (like a battery charging circuit) and you get a usable brake. The regenerative brakes can be used in conjunction with the service brakes for additional braking, and the service brakes have to be used to actually stop the vehicle (the braking effect of an electric motor reduces with speed).