Adding agent ending callback for agent cleanup.

This callback on the listener interface should replace the
interception of the agent process on exit to run any cleanup
logic. Using the at_exit block, while in theory should work, seemed
to be having issues possibly due to the process being killed
unexpectedly. This fix skirts around the issue a little bit but in
general it doesn't seem necessary to run this cleanup in an on_exit
block.