Probing the thermal stability and the decomposition mechanism of a magnesium-fullerene polymer via X-ray Raman spectroscopy, X-ray diffraction and molecular dynamics simulations.