When using buses I always warm my leg muscles up just before my stop. I do this by crossing them and forcing the muscles to contract then letting them relax and repeating this several times. I find it helps me avoid the situation that you describe above. I also get up before my stop so that I have plenty of time to get to the front of the bus.