I tried to close the door quickly right before someone could enter the restaurant.
Why did you shut the door quickly?
I didn't want anyone to see me.
It sounds like you're avoiding people, but it's rather rude to slam the door on someone who is trying to enter.
WTF that's how it works. Doors are not automatic by themselves.
It is fine to close the door quickly, just try not to make it seem like you are doing it to be disrespectful. If there is someone behind you then normally you would hold the door open for them.