I'm a visiting guest. Went in a couple minutes before closing (didn't know it was about to close). I was amazed at the stock and stood watched a little. The next minute I was yelled at.
There are several ways to tell the customers that you are closing. You can turn the light off and on a couple times. You can gently remind the customers that you are already closing and the door will be locked. You can do that a few minutes before closing time. Your customer will apologize and leave as quickly as possible.
Raising your voice, questioning the customer is simply not professional.