Places stop serving food & hot drinks before they actually close -
Because people will sit, and sit, and sit...... And some of them simply to make a point that the staff are there to serve them and they'll go when they're ready and not before, despite 'closing time', because as a customer they're entitled to.
Because telling someone you're closed but having people in there eating and drinking usually leads to the 'But they're here, so clearly you're not closed are you!' or "Can't you just...." argument. So 'We've stopped serving hot drinks & meals" eliminates that argument, does create the 'But the door is open!" Ones though, like you're supposed to lock the present customers in, and like that would stop anyone banging on the door asking the same question when they saw people in there anyway.
(It's the same argument as being turned away when "There's plenty of tables, I can see them!" Argument, yup, plenty of tables with plenty of bookings within the next half hour to an hour and that's not long enough for you to settle, order, eat & drink, settle the bill and for us to clear & reset the table, while serving everyone else.)
Because they may offer takeaway cold drinks & packaged food to go after that time, so that's the part that's open.
Because barista machines can take a good while to clean properly, sanitise the machine, all the utensils etc. Things like the dishwasher need stripping, cleaning and sanitising and because people moan about feeling unwelcome, and like you're rushing them if you do those jobs while they're there, or you're away doing those jobs and they need you that instant.
It's a poorly paid and poorly regarded job, not a calling from God and people shouldn't be expected to finish work late because of the power trip whim of someone else, but that's the kind of service people seem to expect more and more, and that's why there's a shortage of people willing to work in hospitality.
You can demand all you like, but you're talking to fresh air when there's no one willing to meet your demands. People will have to start paying more for the service they want, or accept that if they don't and they pay cheaper prices, the service will reflect that. Service workers don't exist to subsidise either huge profit margins or the leisure time of the general public.
You want places open and serving you until the last second in case you fancy a coffee at any given moment, you need to be prepared to pay what that costs to deliver.