Children need to be able to respond to changes in their setting. If someone has demanded more than once that the child stop the interaction, then the child needs to stop. It should not take several minutes. To keep bothering someone is inappropriate. It does not need to be instantaneous, but if your son is still at it 30 seconds later then your brother in law is right to be annoyed.
On the other hand, adults need to respond to children's undesired behavior gently and lovingly. If you've only asked once or twice over the span of a few seconds, it is inappropriate to scold the child harshly. In fact, if the child believes a harsh scolding is undeserved it may make the child act out worse.
In your case it sounds like the child and the brother in law both need gentle discipline. You can work with the child in the meantime. You could even do a practice:
I'm going to come play with you, but we're going to practice
respecting each others' boundaries. When I say stop, you need to leave
Oof, stop, that was uncomfortable, stop.
Then if the child touches you again, you can gently force him away from you and say "Stop! I said that was uncomfortable. You're being mean to me now."
I find that a legitimate way to make them feel guilty for their bad behavior usually works well. And they should feel guilty if they touch you in an unwanted way.
With your brother-in-law, that's a more difficult one. I'm not sure what the best way is to approach that, but next time they start playing you could say "Remember Bob, you like to stop playing abruptly. Be gentle with him when you want to stop and give him a few seconds." This will work a lot, lot better if you've already worked with your son and he responds well to your brother in law's gentle demand.
I have found that children tend to respond better to my discipline 1) if it comes gently for first and second offenses, and 2) if I make sure they feel loved and respected. Going instantly from zero to screaming at people is neither loving nor respectful no matter who it is done to, I wouldn't want to be yelled at either. Reserve the harsh discipline for major bad behavior.
Summary: To teach your child not to get carried away, teach the child to respect other peoples' personal space and demands to be left alone or to stop activities. To teach your brother in law not to get carried away, tell him to stop playing over a few seconds because your son can't turn it off instantly like a switch.