The reaction of Mg and oxygen (in the air, we have oxygen) is the following:
If we use carbon dioxide (CO2) to react with magnesium oxide (MgO), we can see that this compound would continue to burn. This is because the reactivity series of Mg is above the reactivity of carbon and this compound can take the oxygen from carbon dioxide to react.