You can end it without being rude by keeping it short, polite, and neutral. Here are a few ways:
Use time as an excuse
“I’d love to chat more, but I need to get back to something now. Let’s catch up another time.”
Redirect and close:
“Thanks for sharing, I’ll think about that. I’ve got to step away now, talk later.”
Set a clear boundary:
“I should stop here for now. Let’s continue another time.”
Polite but firm exit:
“I need to go now. Take care.
The key is to sound respectful, but give no opening for the person to drag the conversation on.
Valery well said and thanks for sharing.
Jamie thanks for sharing.

I feel the same way. If I can’t get away sometimes I excuse myself to the restroom.