Anand:
There are two principles at work. One is, when the power is switched off, the collapse of the electromagnetic field induces a current, and therefore a voltage, in the coil of the motor. This manifests as a negative voltage on the contacts (i.e., the previously negative contact becomes more positive than the previously positive contact). In addition, any momentum in the rotor enhances this current in the coil as the motor briefly becomes a generator. Shorting the contacts allows this current to recirculate through the motor, but since it's going in the opposite direction from when the motor was being powered, it attempts to drive the motor in the opposite direction, bringing it to a quick stop. This is the principle on which regenerative braking in electric cars is based. It is also why all inductive loads (motors, solenoids, relays, etc.) are supposed to have a reversed-biased diode across their contacts; according to the first principle, the diode will prevent the potentially dangerous voltage (which can be several times the operating voltage) from entering the circuit and feed it harmlessly back into the load.