Move idlog to global scope.  Now we can catch KeyboardInterrupt and close the idlog shelve.
Correct a typo and add a idlog sync function.
Split finalhop and exithop tasks into their own functions.  This is a step towards partial exit handling.