This has happened to me on a handful of occassions over the 8 1/2 years that I've had UC.
The biggest thing for me is dealing with the anxiety invovled with knowing that it has happened in the past and anxiety that it will happen again without warning! Long car rides, airplane flights, long meetings at work can sometimes be sources of anxiety for me. My best advice would be to do things that either prevent being in that situation or prepare you for the occasional accident. For example, I make sure I get up extra early before work to have enough to get my digestion going with a small breakfast and time for a couple of bathroom visits before I get in the car. It's also a good idea to keep an extra pair of underwear, dress pants, toilet paper, wipes, whatever, in your car. I keep some things in a small bag in my trunk so no one knows what's in there!
Also, if I know I'll be travelling, I try to not eat too much before or while in transit, and once I'm someplace stable(meaning somewhere with a bathroom), then I'll have a larger meal.
I know this probably doesn't help much, but please know that most of us have been there!