I am the absolute worst at this. I know I have to go to bed at a reasonable time, but when lights-out time hits, there I am: on the computer, on my tablet, or on my smartphone, usually doing another lap of YouTube/Facebook/Instagram/Twitter just to make sure I didn't miss anything. And a half-hour later, I'm still doing it.
Sometimes, you need a little helping hand to tell you it's time to go to bed. And since you're going to ignore your loved ones and/or pets for just "one more turn" in your favourite game or one more quick scan through that social media site you just looked at three minutes ago, here's how to set up a helping digital hand to need to provide a little tough love, and get you offline and to bed on time.
Sure, you can set up something crazy in Windows' Task Scheduler to automatically turn off your computer at a set time each day. It's a little bit of an in-depth process, but it's absolutely doable even for Windows novices. You can even make a shortcut on your desktop that automatically powers down your system after a certain amount of time has elapsed. You'll have to activate it yourself, but it's a great kill switch.
That said, I find that den4b's free app Shutter is just as effective and a lot easier to use. Install it, and you'll have two options to set: a trigger (like a set time each day) and an action (shutting down your PC). If you're feeling a little less nuclear, you could just have your system automatically lock at a set time — perhaps encouraging you to go to bed without necessarily killing anything you were working on. You can even have the app prompt you with a little message, like "GO TO BED DAMN IT."
macOS: Parental controls
It's easy to get your MacBook to shut down or sleep at a specific time each day, which can be a great method for encouraging you to get off the computer. You can even make a little shutdown shortcut for your desktop, if you like giving yourself a countdown, or create a scheduled automator action to shut down all of your open programs at bedtime.
If you're prone to powering your MacBook back on, however, you're going to have to get a little tougher with yourself. Consider activating macOS' built-in Parental Controls for yourself, which you can access by clicking on the Apple logo in the upper-left corner of your screen and clicking on System Preferences > Parental Controls.
One quick warning: Parental controls only apply to non-administrator accounts, so you'll have to make a new account for yourself (and reconfigure it, and reinstall all your apps in it).
This definitely puts Parental Controls into the "drastic" category, but if you jump through these hoops, you'll be able to use your administrator account to set a specific bedtime for your "actual" account. This will definitely prevent you from accessing your computer during those time periods. (Pro tip: Have a friend change the password on your administrator account, get them to write it down somewhere, and have them promise to only give it to you in cases of emergency / agreed-upon reconfiguration.)
Chrome / Firefox: StayFocusd and LeechBlock NG
StayFocusd is one of our favourite browser extensions for Chrome, an incredible tool that allows you to keep yourself free from common distractions (like social media) during specific hours. Enable the extension's "nuclear option," set it to run during times when you should be sleeping, and you won't be doing any browsing during the wee hours of the morning.
You can't get StayFocusd for Firefox, but LeechBlock NG lets you restrict your browsing habits in a similar fashion. Be stingy; no social media before sleepy sleeps.
The best way to keep yourself from playing with your smartphone when you should be sleeping is to just not keep your device anywhere near your bed. Put your charger over on your desk or, better yet, in another room. Ta-da! ...unless you use your smartphone as your morning alarm, like many do, which means you'll still need to have it somewhat near you to wake you up.
Pony up $US4 ($5) for the premium version of Moment for iOS, and you can set the app to nag you with notifications during scheduled time periods. Though you'll be able to "use" your smartphone, it will be far too annoying and cumbersome for you to actually get anything done, and you might then actually go to bed.
On Android, give Tasker a try. Though you can't use it to turn your smartphone on and off at a set time — if only — you can at least schedule times for when you want your device to flip into aeroplane mode (if rooted). Otherwise, you could just have Tasker turn your smartphone display's brightness down to nearly nothing when it's bedtime and flip off your wi-fi and mobile data to discourage you from using your smartphone.
You can also get a little crazier and have Tasker close all of your apps at a set time, but this requires a bit more configuration (and some other add-on apps).
Your router might be able to help, too
Most modern routers typically have some kind of option, usually buried deep within their settings screens, that allow you to schedule your wireless connection. In other words, you can have your router power down your wi-fi at a set time — like bedtime — and power it back up in the morning. While this won't help you if you just burn through your smartphone's data plan instead of going to bed, you can at least keep your wi-fi-only devices offline, ideally making you less likely to use them.
Some routers even come with more comprehensive blocking systems, typically as part of their parental controls, that allow you to keep specific devices from accessing your wi-fi at scheduled times. Again, that doesn't do you much good if the devices have another way to connect online, but it's a start.