I’m purely just guessing here but it must be a demand thing. Probably cheaper and more cost effective to close if there’s less demand after 4pm for most coffee shops. I know I can’t touch caffeine after 2/3pm or I will be awake all night so would never go to a coffee shop after that time unless my intention was to actually be up all night.