If you want to stay off Facebook during the day, block the site during those hours. If you want to be off the internet, entirely disconnected, turn off wifi and mobile data. Put your laptop and phone on flight mode. This idea applies to more than just avoiding distraction. It’s works with all behaviours. If you want to stop drinking, don’t go to bars in the evening. Give away all the booze stashed in your fridge and don’t buy anymore.
Sun Tzu makes the observation in The Art of War that the greatest generals are those who win without fighting. Who win before the fight even begins. In the same way, those who deploy their most precious resources—time, energy and attention—with the most effectiveness are those who avoid compromising situations altogether. They don’t have to struggle against negative behaviour because they’re made it near-impossible in the first place.