Cool! Here are some quasi-random thoughts.
If it’s useful, the clocky aggregation method can manage the subtraction of two times.
Part of your morning routine could include planning to leave the office, and setting things in motion to make that a real commitment.
If you’re on iOS, then setting a GTBee task could be useful; unless I mark this as done before a certain time, charge me!
You may only need to automate the physical leaving, not the intent-to-leave. I can imagine myself entering the intention to leave the office within the hour at a certain point, like setting an un-ignorable alarm clock.
Before going down an automation rabbit-hole, you could try the simplest possible manual option, and use that to learn which parts you’re ever tempted to weasel about, and automate those.
For verifiably arriving somewhere, I use Swarm (foursquare) to check in, such as at my gym. I worry about multiple datapoints if I were to use some kind of automated geo-location.
Just having to enter the time manually may be enough to cause a change of behaviour.
If facebook is the demon that keeps you in the office too late, blocking software might be helpful.
Regardless, keep us posted! There are a bunch of arbitrary-trigger based goals that it’d be good to beemind better.