We’ve all been there — in the middle of a party, surrounded by fun people, fun music and fun cocktails, but sucked so deeply into the most unfun conversation with the person who just won’t take a breath.

“She wants your ear,” said Amy Alkon, sassy Advice Goddess blogger (AdviceGoddess.com) and author of “Good Manners for Nice People Who Sometimes Say (expletive deleted).”

“I love my ears,” Alkon added, “and she’s not getting them.”

Tolerating a conversation you don’t want to be in doesn’t make you more polite. “It’s not self-compassion if you’re sitting there and you want to put a screwdriver into your ear so you don’t have to listen to the person anymore,” Alkon said.

You can politely extricate yourself from a conversation, but there’s a science to it.

“At the root of manners is empathy, and this is actually what you need to know to get out of these conversations, because you can get out of them while being kind,” Alkon explained. “And that’s the really important thing. You use a bit of behavioral science research.”

Here’s Alkon’s advice:

Give a reason. Alkon cites a study by social psychologist Ellen Langer that found that people are more apt to comply to a request, even a ridiculous one, when given a reason. So, your key is the word “because.” Almost any reason will work in this case, Alkon said — because there’s something funny about your drink, because you need to run to the bathroom, etc. Just remember to follow through.

“It’s really important to be kind, it’s better if the person sees you going to the bar or on your way to the bathroom,” she said. “That will allow them to feel OK about you ditching the conversation.”

Use hand signals. Be more “European,” Alkon said, and stick your hand up while saying, “Wait, excuse me, I need to use the restroom.”

Although it might feel rude to interrupt, ignore that pretense. “That person doesn’t have the right to suck all of the air out of the room and keep you there, but they’re pretending that they do. You have a right to not sit there and be a slave to their lips,” she said.

Use the buddy system. “There are just those people who ‘Velcro’ themselves to you and follow you around like a dog after a piece of meat,” Alkon said. She suggested having a prearrangement with a friend so you can rescue each other from such a predicament. But don’t forget your manners. “Just say, ‘So sorry, I just have to borrow her for a minute because I have to tell her something.’ ”

Never be rude. Don’t just walk away abruptly, don’t cut someone off and say you’ve heard it before, don’t say you’re having a seizure, Alkon said. “There’s that ‘because’ Band-Aid thing [that lets you get] what you want without being hurtful to another person. You don’t want to tell someone they’re an old tiresome bore, even if they are.”