The problem is you're giving criticism way too much power over you. When you replay a conversation in your head and come up with the perfect response, you're actually prolonging the conflict - your brain thinks the situation isn't resolved yet. You need to close it for yourself somehow, and it doesn't have to happen in reality.
A simple trick helps: when you catch yourself obsessing over the conversation again, ask yourself honestly - could this criticism have some truth to it? Not because the person criticizing you is right about everything, but just look at what they said without the emotions. If there's something to it, think about what you'll take away from it. If it's just someone's anger or straight-up lies - acknowledge that it's about them, not you, and let it go. After that it's easier to notice when your brain starts replaying it again, and just tell yourself: "Okay, I've already dealt with this."
Over time you'll just stop holding onto hurt. People often say stupid stuff in the heat of the moment, they forget about it in a day, but you're still stewing over it a month later. That's unfair to yourself.