I keep myself going by setting personal deadlines: I don't browse the internet if I 'need' to finish something before, say, going to lunch.
EDIT: Also, before stopping work, I always try to have a good idea of what to do next. It's much easier to dive back into work because I know what to do, and my subconscious has had time to think about how to do it. This was inspired by Hemingway's 'hack':
"The best way is always to stop when you are going good and when you know what will happen next. If you do that every day … you will never be stuck. Always stop while you are going good and don’t think about it or worry about it until you start to write the next day. That way your subconscious will work on it all the time. But if you think about it consciously or worry about it you will kill it and your brain will be tired before you start."