Depending on the conversation or situation you are leaving, generically you may say, "okay", <then walkaway>. Body language in this case can speak louder than words and is culturally acceptable in American culture. I am not sure about other Western cultures. In most English speaking cultures , it is probably okay. If the other is looking away, that is your cue (chance) to leave.
Could be different in countries where English is a major second language as the Philippines and/or Singapore (Singapore...probably okay). In most cases, the above is okay.
At a party, could say, "I have to go" or "pardon me", then leave.
To be polite, it is not so much as telling them to leave. It is more about you leaving them.
If it is impossible for you to leave, such as if they are a guest in your home, tell them, "pardon..." followed by a real reason..."I am getting tired", etc. Telling the person that they are boring or you do not like them is not what you want to say. Among many polite things you could say, "I have to...go to the bathroom...am busy...chat with you later" <then show them out>.
The key is say something that allows you to leave. Do not tell the other to leave.
You leave first. You get the same result as they leaving. It is okay to just say, "I'll be leaving now" when you can leave out of the sight of the other.