Muscle cramps happen when your muscles tense up and you can’t relax them. While painful, usually you can treat them yourself. Exercise, dehydration, and menstruation are common causes. One way to stop cramps is to stretch or massage your muscles and to eat enough of these key nutrients: potassium, sodium, calcium, and magnesium. They’re called electrolytes, and you can find them in the following foods.