When I used to race I'd always, without fail, cramp up towards the end of the last lap, whatever the race distance. Sometimes it waited until the sprint. I tried most things that others recommended to take....bananas, quinine tablets and various concoctions. Nothing seemed to work. I don't get it so much these days since I packed in racing but get it after a long ride, usually when I'm relaxing watching the Tele or reading a book. There's nothing quite like the pain of a good attack of cramp 😂