Or you could have put it away. I've done that--about the third person shows up, and it's clear that people are going to be descending, I've gotten up and said, "I'm going to put these away or out of sight, here behind me on my desk, if you want them. That'll discourage other people from other departments."
I understand how it can be really daunting to essentially say, "We don't want to share with you."
And honestly, all those people who came to get candy were anywhere from sort of wrong to really wrong.