Don't think one can find a plugin for Moodle that does such, however, via 2 cron jobs ... one called 'open' which would use the maintenance mode script in admin/cli/ of code @5PM and set to disable - thus site available to all.
The other cron job called 'closed' sets maintenance mode to enable and executes @6PM.
Won't keep admin level users out.
Bad thing about setting up this way ... can't run overall cron job for moodle while in maintenance mode.
With a little imagination one could possibly cron a redirect rule for open access to closed and vice versa ... which (I think) would still allow the running of cron for Moodle.
Note: have never really done above ... you know what is said of 'best laid plans', right?
If the purpose is simply to restrict students/teachers from screen time, just cause moodle is un-available won't accomplish that. Matter of fact, thinking differently, the more time a student spends in the moodle, as opposed to YouTube, student might discover 'getting something' that she/he hadn't before.
Curious .... have to ask ... why? What's the reason?