|How can a battery lose energy when it's not being used (like when it sits in a flashlight that's not turned on for months or years)?
The battery maintains a steady positive charge on its positive terminal and a negative charge on its negative terminal, month after month. These opposite charges attract one another and they do manage to get back together occasionally. They usually travel right through the battery itself, assisted by thermal energy. When that happens, the battery has to pump additional charge from the negative terminal to the positive terminal to make up for the lost charge and consumes a little more of its chemical potential energy. You can slow down this aging process by refrigerating the batteries. With less thermal energy available, the accidental movements of charge through the battery become less frequent.