If the questioner is an acknowledged PITA, I show them my business card. On the reverse:
Programming rate = $100/hr
Programming + answering questions = $150/hr
Programming + answering questions + your help = $200/hr
I'm usually left alone.
Usually when I show up to look at something, everybody else heads on break or to the smoking area.
Several times over the years I've simply handed the offending person my laptop and asked them to let me know when they are finished.
Probably not the most constructive way to deal with the problem, but it's worked every time I've used it.
The other thing I was taught in a stamping plant years ago was if someone was standing around while you were working was to stop working, turn around and watch them standing there.
Also, there was frequent requests for tickets. No ticket - no show, or $10 cash each
Plus, I give them the "Let me know when you're done" line and walk away for a break.