I have recently found that taking 200mg of magnesium citrate/glycinate with my evening meal sets me up for managing waking up during the night really well. I now manage going to the toilet (keeping the light off) and getting back to sleep without any racing thoughts taking over.
From what I have read, it is apparent that endurance athletes can have a magnesium deficiency and that taking the required supplements can rectify this as well as have a positive impact on your bodies ability to cope with stress and anxiety. This has certainly been the case for me.