The tricky bit is avoiding a double-dip for XP. For example, you de-escalate a fight through a dialog and you get XP for that peaceful solution, and then you quickly turn around and kill the enemies to get even more XP by fighting them.
To avoid that kind of exploit, a game can simply pause the scene while the enemies retreat, not allowing player action. The scene where you can talk your way into rescuing the Goblin at the windmill without a fight almost works like that, without a forced pause. The goblins disappear pretty fast.
But not every situation lends itself to that. For example in the Zhentarim hideout, you can defuse a fight by turning over the chest to the leader, then wander around, trade with one of them, and deal with freeing the Artist if you want. Or.... you could turn around after delivering the chest and kill everyone for the XP. The writer of that area want the Zhetarims to persist, not magically disappear after defusing the encounter.
The way to solve that could be to have a flag that prevented XP gain from kills in that area if you've already received XP by avoiding the initial fight. That could seem a little weird though, since players are used to seeing the XP after every combat. And the programming would have to account for every possible combination of actions by the player. It's easier just to award XP for kills, which I guess is why so many games work that way.