Improved thermal stability of gas-phase Mg nanoparticles for hydrogen storage