The real problem with working from home is the fact that you really don't have any restrictions as to when you have to work. Even contract-based projects with schedules you have a deadline to meet, but whether you choose to work two 12 hour days and take off the next two or work four 6 hour days is really up to you (barring any needs such as regular team meetings, asset delivery based on dependencies, etc). Okay, so I can understand how regular workers who go to the office from roughly 9-5 (and I say roughly because "office hours" in the industry still vary widely) might see being able to work whenever as an advantage, but in many ways this is the one curse of working at home.
Where you have access to your office.
All the time.
See, the discipline needed for working from home isn't knowing when to work, it's knowing when to stop working. You wanna know the fastest way to crash and burn? Working from home is it. People who work in a office take for granted the fact that when they leave for home they're essentially free from work until they return the next day. Sure, perhaps you can log in remotely from home if you need to check up on something real quick, or forgot to fire off some email or remembered a file you missed checking in before leaving, but essentially - mentally - you've left your work environment.
However when you live in your work environment, things are a bit different. A lot of people solve this simply by making sure that the place where they do work is its own room, devoid of any other purpose whatsoever (tax write-off, anyone?). This is a very good thing to have if you can. Still, things can remain difficult being that you're always just a few steps away rather than a few miles away from your office.
Let's look at it this way. It's the dead of night, and you're trying to get some sleep. All of the sudden POW! A solution to a problem you've run into with some code suddenly leaps into your head unbidden out of the ether. You sit up in bed, mouth agape that you didn't think about it earlier while you were at work. Ah well, you say as you lay back down, I'll be able to do it first thing in the morning when I get back to the office. Perhaps you'll scribble a few notes before going to sleep so you don't forget.
Now what happens if your office happens to be right next to your bed? Or a quick sashay down the hall? Don't even deny that the burning desire to immediately implement this solution won't boil up in your brain, denying you sleep until you get out of bed, sit in front of your computer and do it. Before you know it, it's 6am, the sun is rising and your sleep pattern is now completely out of whack.
It's hard to imagine if you haven't experienced it yourself, but it's surprising how different the mindset is when you're working from home than from an office (or rather, a "remote location").
I feel like I'm on the verge of rambling, so I'll bring this to a close. I just find it interesting how common the misconception of working from home is. All my friends are like "dude that's so cool, you can work whenever you want?" Yea, I guess it is cool, until I drag myself away from my desk and realize I really should have done that like, 5 hours ago and suddenly fully realize how hungry or tired I am.
If it's easy to make yourself start, it can be hard to make yourself stop. And there's really no one to make you stop except yourself, so you have to learn to know when to let issues rest for the day so you can return anew the next.
And yes, having a spouse or significant other around to yell at you to get off your damn computer and come to bed is effective as well. If you have the calvary, more power to you. Thank them before you go to bed k?