I believe that can happen if you have several batteries wired up in series (as here) and one or more of them is substantially weaker than the others. If you keep operating the device beyond the point at which the weakest battery runs down to zero, the other batteries will keep pushing current through it. This can create a situation called "over-discharge", and depending on the specifics of the battery chemistry it can cause the over-discharged battery to "charge up in reverse" a bit, and develop a reverse-polarity output voltage.
Over-discharge will damage NiCd (and I suspect NiMH) cells, and I believe it can cause alkaline cells to start leaking.
The better brands of alkaline batteries usually come with an on-the-package warning that all of the batteries in a set should be replaced at the same time, and that you shouldn't mix different types of batteries in a set. This is why. You really want 'em all to run down at the same time.