Work with goals, not with hours
If you work by hours you perform pointless tasks like checking your email or Skype too often just to feel like you're doing something but you're not actually working. You're just trying to find ways to procrastinate while looking productive.
In a typical office setting it is the norm to work for 8(+) hours no matter the task. Even if you've finished what you were supposed to accomplish for the day you still have to fill your hourly quota. More often than not you are going to find yourself with an additional task as 'reward'.
Since I've started working on my own I started working based on goals instead: Today I want to have this specific feature done. At times it might take 8 hours, at times it might take 10, at times it might take 6. This forces you to focus on the actual piece of work without splitting your attention over multiple tasks and without checking the clock.
The focus should be on getting work done, not on how many hours you put in. I'm not advocating working 16 hours a day and I'm not advocating working 2 either. When you are planning your day you should have a rough estimate of the time commitment of the task you're planning to accomplish for the day. Don't pick a task for the day like 'move the button 3px to the right', you know it's going to take 30 seconds to implement. At the same time don't take as task 'overhaul the sync system', it's surely going to take way more than a day. Learn to break down your tasks and work on chunks of them. When working with goals the planning phase is just as important as doing the work.
In an office
It is harder to make that work in an office setting. There are multiple challenges both on the management side and on the employees' side. Nobody likes the guy who always leaves before everybody else. Peer pressure is real. If you're working remotely something like this might be doable, but if you're working on site in a traditional office setting it is almost impossible. A lot of companies don't really care about how much you do unfortunately, they only care about the number of hours you put in and being more efficient only translates to an ever-increasing workload with no benefits. Bosses who understand it are rare and far in between.
That said we're going to focus on the remote side of things where employers are a bit more open-minded.
You need to make it clear from the start to your manager about what you want to do and what the goal is. Otherwise, once you finish your task you're just going to get assigned more work until the 8 hours have elapsed.
If you prove yourself as a hard worker the company might be more inclined to try something similar. You need to show that you can still bring results and you can handle your workload even while deciding the hours yourself. It is not something suitable for everyone though so don't fret if it's not for you, there is nothing wrong with that.
I don't really understand this behavior from companies, acting like this only encourages good employees to either limit their efficiency (so that they don't get assigned even more work) or open their own company (so that they can decide how to handle their workload).