This could be due (in part) to magnesiums pharmacological effects, particularly blocking glutamate (NMDA antagonism). This has some positive effects on the dopamine system (the "D2" receptor), alongside general relief from excess glutamate (excitotoxicity).