Rework shutdown

This set of patches is intended to make sure that the agent will reliably stop after a reasonable time if it has been requested to, even in some corner cases.

I removed the counting of shutdown requests: One request needs to be enough in case of for example a shutdown of the host or an automated restart.
Good point and yeah that would be better.  The best solution overall though would be to fix it up with callbacks instead so we have more control over the exit flow.  It would also be better this way because it provides a better guarantee  of shutdown sequence than callLater would.

That said...I think we may be better off trying to address these changes in another PR.