When magma reaches the surface gases what out of it