To me, attacking someone trying to run past you is a no brainer unless you are currently occupied. Animals do it.
And attacking the person you see as a most serious threat first is common sense too.
But AoOs and Oppy attacks are not the best way.
Limiting movement or action of the active character is probably better.
When you are attempting to withdraw from a fight or move out of an enemy's range from melee.
1) Take a Dodge action and move normally.
2) Take another action at disadvantage and move normally
or
3) Take another action and move half speed.
And attacking the person you see as a most serious threat first is common sense too.
But AoOs and Oppy attacks are not the best way.
Limiting movement or action of the active character is probably better.
When you are attempting to withdraw from a fight or move out of an enemy's range from melee.
1) Take a Dodge action and move normally.
2) Take another action at disadvantage and move normally
or
3) Take another action and move half speed.