Similar happened to a mate of mine in Germany. Took money from the machine and walked out of the kiosk. The door closed automatically behind him as they do over there. Then he saw he left his money in the machine and went to go back in. Once the door opened the money went back into the machine. He had to get onto the bank and they had to go through the security tapes to confirm what happened, before he got the money refunded to his account. It took a few weeks.
Don't think the ATMs here take back the money any more, but if you were inside a bank you might be lucky and they can see it on the security cameras, if outside or using the ATMs in shops, you'll probably have to write it off I'm afraid.