The short answer is: yes, it does matter.
I did exactly this a couple of weeks ago. My work visa ran out on 28/07, but I went to Macau on the night of the 25th and returned early on the 26th, and was refused a visitor stamp. I was told both by the staff at the border (who were unfailingly friendly and helpful about it, by the way) and by staff at Immigration the next morning that I should leave on the 28th and return on the 29th or later. I do like Macau, but going twice in one (extended) weekend was a bit much...
When I re-entered on the 29th, I was asked if I was working, and given a visitor stamp without any delay or further questioning. Nobody at the border or at Immigration seemed to have any problem with the idea of switching from work to visitor, so I could hang around long enough to hear the result of my QMAS application
Edit to add: Of course, if it's just a case of 5 minutes, you could just hang back so you don't go through the border until after midnight. They do count 1 minute past midnight as being the 'following' day. That might not work quite as well if it's 24 hours and 5 minutes, 48 hours and 5 minutes, etc.