Answer
The generator-like action of the alternator in a car occurs while the engine is running and keeps the battery fully charged.
Work Step by Step
The generator-like action of the alternator in a car occurs while the engine is running and keeps the battery fully charged. The headlights would discharge an old and failing battery quickly if it were not for the alternator action. When a battery is in bad shape, the engine and the alternator must do more work to keep the battery charged when the headlights are on. Therefore, when the battery is failing, the engine of a parked car runs more "quietly" when the headlights are off than when they are on.