It takes a lot of will power. I am struggling to break the habit myself.
My daughter, since she was in high school, made a rule for herself not to eat or drink anything but water after 8:00pm. Although it was not ironclad, even in college she made an effort to stick with it - to a greater or lesser degree (and likely never on weekends). After college, she does pretty well at it although now she is working late hours and that makes it a lot harder.