Agree with the above statement that this is considered blunt and not polite.
Here is a way that you can head out on your way, with a smile and a friendly look in your eye.
"It's been so nice talking with you, but I've got to get on my way."
This way you have given them 3 positive messages before the negative one.
1. A smile.
2. A direct look into their eyes.
3. A compliment on your enjoyment of being in a conversation with them.
If you and the receiver are comfortable with physical communication a 4th can be used.
4. A handshake, a touch on the arm, or even a hug goodbye.
Eveyone is busy.
When you say you've got to go, using these positive reinforcements,
the other person feels good enough about the conversation that their feelings are spared.
If you simply want to move on to speaking to someone else and are not leaving,
it is acceptable to simply say, "It's been so nice talking with you!" as you get up with a smile, a friendly look, and and physical touch (if desired).
Grammar and culture. :D