At every institution, there exists a person with too much time on their hands and a complete inability to read social cues. Like a mascot to a sports team, there is at least one located at every place of employment.
They corner you at the vending machines, in the bathroom, on the elevator, in the hallway and talk your damn ear off. Not for two or three minutes, but for 10-15 minutes or even longer. You try your best to get away. You might move toward the door, stop making eye contact or just walk away, but it doesn't work because they tend to follow in order to continue the conversation. You might try verbal clues, including the yes or no answer only approach (don't engage further), add some slight irritation to your voice or even flat out say you must go, but all attempts fail because there is always just one more thing they need to say or ask. The worst part is that these are typically very nice and well-meaning people and you don't want to hurt their feelings. If they were jerks, the problem would solve itself.
My solution is to use my timer in a preemptive strike. When ever I see these people or know that I must visit them for whatever reason, I set my timer for anywhere from 2-10 minutes. Two minutes for a random run-in, longer for a work-related visit (i.e. getting something signed). Once the timer goes off, I stop it and inform the other person that I must stop a gel or incubation or whatever. Then I scurry off, looking every bit determined and busy. It works like a charm. No feelings are hurt and my productivity is not impaired.
This does require that my timer is always on my person, but I am always timing something so for me this is no big deal. It also requires you to set your timer without looking at it, as is the case for the unplanned run-ins. Alternatively, you can preset your timer for 2 min every time you venture to the vending machine so that you must only hit the start button when you spot the chatter box.