Gas/diesel/whatever have energy density of zero.
If somebody were to make petrol/oxygen stoichiometric soda, damn right I wouldn't want to be near it either.
The key difference is the hydrocarbon "battery" has a volumetric energy density of around 12kJ/L if you include both halves where the sulfur one is still around 7MJ/L
Perhaps I am misunderstanding, but that sounds almost like a calculation that applies to a vacuum, not a pressurized atmosphere with plenty of "free" oxygen? Perhaps that's the same for the TNT & battery, so maybe none of these calculations are directly applicable to real-world scenarios?
The point is the kg of hydrocarbon is less able to release its 40MJ all at once because the oxygen which is spread out over 4000 times as much volume needs to get to it. The battery contains both ends of the reaction, but the hydrocarbon only contains one.
TnT or nitroglycerin is much more dangerous in spite of much lower energy density because the energy is all in the TnT.
Of course this isn't the only consideration (the fact that TnT releases nitrogen which suddenly wants to be much bigger is important, for example), but it is a reason to hesitate around such a battery and carefully consider whether you want to throw it around at 100km/h.
I could see the concern, though a car is basically always going to require you to drive around with a potentially lethal amount of energy regardless of the storage medium. Also a battery failure does not mean all energy is released simultaneously. A denser battery could result in a smaller battery that could be better protected from damage.
And it's far more common for ICE cars to actually explode/burn out. And particularly petrol fires can be very dangerous and lethal. Cars can combust while parked, while driving, or when you get in an accident. It's one of the most common causes for fire brigades to have to take some action. Diesel is a bit safer than petrol but it will burn if things get hot enough. And cars and trucks overheat and catch fire for all sorts of reasons.
EVs are much safer both in absolute numbers and relative numbers (if you consider there are far less EVs than ice vehicles). They do occasionally burn of course. And usually those fires aren't very explosive and give you plenty of time to get out of the vehicle and to safety. Fatalities/injuries are rare with this.