I've had two experiences with extreme range anxiety, both more or less on purpose. The second time was at Craig Vetter's mileage event last July 4th, where I was trying to finish an 80+-mile, mostly freeway course without recharging at the midway point (I got to the midway point with 52% left and figured I could make it back, since it was mostly downhill...but I neglected to consider the prevailing wind, which was a tailwind out and a headwind back in).
The first time, I just wanted to see if I could get up to Julian from El Cajon, which is about an 82-mile round-trip from my place, but no freeway speeds involved -- it's a beautiful mountain road up to Julian and back down to El Cajon. I found out I can do it if I don't mind pushing the last few hundred yards.

Actually, I passed my local 7-11 maybe 1/2-mile away from home, though I'm sure they'd allow me to plug in for a while, because I still had 4% on the clock. But from there, it's an uphill grade home, and those last few percent disappeared mighty fast! Being so close to home, I jumped off and started pushing, but when I came to a nice stopping point, it occurred to me I should try to run the bike again. I jumped back on and it gave me power, enough to get me to my driveway -- I had to push the last 10 feet.
So, if I was near home, I think the first thing I would do is just wait. The voltage of a battery pack, especially a tired battery pack, tends to sag under load, and it will slowly recover a bit when you remove the load. So turn the bike off and wait for several minutes. The battery voltage may recover enough so the BMS will allow you to ride a few hundred more yards. If I'm not mistaken, Richard had a ride where he was successful in getting home by resting the battery several times, getting him the last little ways home.
Also, don't hesitate to just ask if you can plug in somewhere for a little while to get enough juice to get home. On the Vetter ride, I pulled over and asked at a gas station if I could plug in -- they were more than happy to let me juice up for an hour, asking me questions about the bike and generally acting excited that I'd chosen their gas station to recharge at. I'm also still convinced that my local 7-11 would have been happy to let me grab some juice -- god knows they've shown lots of interest in the bike in the two years I've had it.