Researchers at U.C. San Diego typed in a pin on the left. Then immediately took a digital picture of the keypad with an infrared camera. The camera picks up the heat pattern of each of the four numbers that were pressed and they have it in the right order.
You can prevent this from happening by hitting the key that says "No, I don't want another transaction." Effectively locking the machine or just by putting your hand over all the buttons.