Your body cannot be without magnesium so you cannot just stop it.
Some people use magnesium chloride in their baths to absorb the magnesium through their skin which can provide some much needed magnesium without it going to the digestive system.
Biofilms use magnesium and other metals so that is worth considering.