Even if you do those things that benefit your company however, in theory at least you should have reported back that your task is finished, and you'd usually be assigned with what's next on the priority list... So still the temptation is always there.
It's a gray area, but if my task touches module A and I spend some extra time cleaning up module A, or writing tests for it, my conscience is clear. Or if I finish a deployment script but think reading a Chef tutorial might teach me a better way of doing it next time, sure. The work may not be finished just because "it runs." I wouldn't fill up 4 hours with that kind of thing, but 1, sure (depending on the urgency of other tasks, etc.).
I guess it also depends on your company culture and your boss's/client's expectations. I have clients who would get upset if I billed an extra half hour, and other clients who want me to spend that hour on tests/refactoring.
I'd say if you have extra time, use it productively for some of those related-but-inessential tasks that rarely get budgeted for, like refactoring, optimizing, writing tests, experimenting with new tools, etc. Spend the time on things that benefit your employer/customer but will also improve your skills or make life easier for you.
I've done this a few times in my career when I inherited a big poorly-written codebase. Whenever I finished a task early, I'd spend some of that extra time making improvements. Over a few years you can really make a difference. And those improvements are the kind that will let you continue to exceed expectations in the future.