Screenwriters love defibrillators because they're dramatic (and because electricity is magic in Hollywood), but they're almost never used right on TV or in movies. Electric shock is effective only on ventricular fibrillation (the heart quivers instead of beating) and ventricular tachycardia (the heart beats very fast); it does nothing for asystole (no heartbeat at all, commonly known as a "flatline").
In other words: don't shock a flatline. If someone's in asystole, use CPR.