I learned at the first sign of leg cramps to push your heels down, increase your cadence, and reduce the power applied to the pedals. Your speed will slow, but you will spin it out. And keeping your heels down will stretch the muscles in the back of the legs.