In this question, one of the answers talks about ending conversations before they get awkward.
Once you think a conversation is going to get awkward, how do you end it?
I've had this problem in the past, both at social events (when I'm talking to someone and really can't break off the discussion) and online (messaging someone via Facebook, for example). In the instances I've experienced, I'm typically talking to a close friend or family member. This can make things either easier or harder, depending on the person and the exact situation.
My typical conversation-ending excuse is that I have to be somewhere. This can be easier if I'm at a large group function, like a party. I might say, at a pause in the conversation,
Hey, I told [Person X] that I'd spend some time chatting with them today/tonight; it's been a while since I've seen them. If you don't mind, I'd like to pop over and see them for a bit. Will you be around for a while, so we can talk more later?
I've found that people are largely agreeable to this, for a few reasons:
It's also possible to use the first tactic here, but modified:
Hey, I told [Person X] that I'd meet them for [coffee/lunch/a walk/homework/a date/etc.], and I have to go in a couple minutes. I enjoyed talking to you; [insert question about getting together again].
The key here is the last bit: Letting them know that you do, in fact, want to talk to them. You leaving is not in any way a reflection on them personally; it's just that you do have other things to do (not necessarily involving another person - maybe you have to drive somewhere, for instance. To be honest, long conversations can take up too much time. I've been there, trying to end a conversation with a friend because I need to get dinner, meet up with someone, or even go to sleep.
You don't have to be specific about the issue - I rarely am - but you should still emphasize that you enjoyed talking with them.
Things get a little easier if you're talking to someone remotely. If you're with someone in person, you've dedicated some time exclusively to them; you're expected to actually use that time to talk and do stuff. On the other hand, if you're calling a person, texting them, or, say, Skyping them, you might be in the middle of doing something else, and you've set aside Y minutes to briefly reach out to them.
For instance, I'll sometimes message with a friend if I'm taking a study break. I set aside ten minutes in the middle of a problem set to relax and refresh myself. Occasionally, they'll be in the middle of a block of free time, so they'll be a bit chattier. At the end of the ten minutes, I'll emphasize that I need to go finish my task:
[Make a comment to sort of end the thing you were talking about.] Anyway, I have to get back to my [problem set/studying/reading/note-taking]. I don't want to take too long of a break! I'll see you [at school/at dinner/at practice/tomorrow/etc.].
I've done this plenty of times, and I have yet to use it and not have the other person understand.
Things are a bit trickier if neither person has to be anywhere, i.e. if you both have free time. I sometimes talk with my family and friends from elsewhere over Skype at night, and there's no set cutoff time. This is a place I've had trouble in the past. Usually, things work out best when I mention that I have to go to sleep, if it's getting late (as should they, unless they're in a different timezone!).
All of the above can be a little bit trickier if you're talking with a family member, significant other, or close friend. On occasion, I've had pushback when I try to use one of the above reasons (but only when I'm close with the person - and not often). This is because the other person might feel that you should spend more time with them than Person X, if you know Person X - especially if they still want to say something, but haven't yet gotten it out.
The other person should respect your wishes if you really need to do something else or be there. If you have a good relationship, then they know you well, and it's up to them to accept that you do (sometimes) have other things to focus on.
Ending a conversation with a person you're close to might be a bit harder, but it's still important that you end the conversation if it's getting too long, and it's negatively impacting you.