Figure below show how to use a diode or a electrolytic capacitor to protect circuits using relays against spikes generated when the relay turns on and off. The high voltage spikes can destruct semiconductor used to control relays and other inductive loads as SCRs, transistors and others.