I think a good general rule is always set up the conversation with a general end-time in mind, an "out". Drop something in like mentioning you are on your way somewhere, answer a couple of questions, ask a couple of questions, as soon as your genuine interest wanes, remind them of your previous engagement....
I'm a fan of the say what you mean strategy. Meaning, I personally try not to blame myself if the conversation is awkward. If there is a strange or uncomfortable vibe that I cannot interpret, it means the other person probably isn't saying something and their feelings are going out into the ethers; what I sense is the inconsistency. Someone (usually not me) is not being completely honest. And if that is the case, it is not your fault. When did it become important for everyone to be a mind reader? I excuse myself and go. "Well, it's time to get on to my meeting/doctor appointment/phone call/animal feeding time". I guess the thing I pick up on as the "uncomfortable vibe" is my cue to leave.
I think I have lost a lot of potential friends because if I feel uncomfortable at all I will excuse myself this way. And it is possible that I overgeneralize the feeling. Time spent in a conversation wthout clear signals either way is directly propertional to the length of that relationship. In other words, the longer you have known me, the longer you have to put up with me. There are other factors, like my interest level in the conversation. If it's not clear, I'll usually bolt at the firrst sign of a conversational lull, relying on the "out" I planted at the beginning of the conversation....