First this didn't happen on a boat, it happened to me at work. It could easily have been aboard a private vessel.
The natural gas powered emergency lighting generator at our facility was not working. Upon investigation Thursday it was discovered the battery, an automotive starting type, was low. It seemed the tickle charger incorporated into the system had perhaps failed. Not a problem, a charger was connected to the battery and set to charge automatically at max of 5 amps. The following day, Friday, I went up to investigate the state of the battery and to attempt to start the generator. I hit the start button on the generator and heard the tell tale clicking indicating the battery still lacked the power to crank the genset. When I released the start button, bang. The battery exploded, splashing me with fluid on my clothes, arms and face. After unplugging the still connected battery charger, and doing a cursory check to make sure there was not other issues that might cause a larger problem, I went to wash the splashed areas. In the end, I was fine and there was no significant injury.
The good things: I was wearing safety glasses, hearing protection and long pants.
The bad things: The battery was not in a battery box, so the explosion went everywhere.
In hindsight I'd guess the faulty charger cooked the electrolyte out of the battery and the additional charger compounded that problem. Try to start the generator created a spark internal to the battery and ignited gases in the battery.
Feel free to opine.