On leaving in the middle of a conversation

I usually like talking to people.

One of the people I talk to most these days is my work colleague. He has interesting viewpoints and is knowledgeable about subjects I’ve never considered finding out about. It makes lunch breaks more like lectures, but it’s fascinating and I’m learning a lot. 🙂

Today, I had to leave work early for a doctors appointment. I needed to catch 3 trains in a row in order to get to the doctors on time. My colleague, however, was in a very talkative mood, more so than usual, and kept bringing new ideas into the conversation I was trying to get out of. I am exceedingly bad at not answering questions, and I don’t like cutting people off mid-sentence…

I ended up leaving 10 minutes later than planned (which wasn’t actually as bad as it could have been because I managed to catch an earlier train than on my connection plan. Also the doctor in question never runs on time anyway).

So.
How is one supposed to excuse oneself from a conversation without being rude??