They've been using this for fuel cells in auto racing for years. The fuel is suspended in the foam and prevents it from sloshing and it also prevents it from atomizing in the event the cell is ruptured.
http://www.fuelsafe.com/store/enduro-cell/core-cells.html
While Im sure this helped, there still was a certain amount of luck too by having no ignition sources (from the plane, or externally) to ignite the avgas that had spilled onto spectators and in the surrounding area.