Global cleanups

Clean up all known global datastructures at shutdown.

This should make leak detection much easier.

Typical valgrind output after this:
==5897==    definitely lost: 0 bytes in 0 blocks
==5897==    indirectly lost: 0 bytes in 0 blocks
==5897==      possibly lost: 1,903 bytes in 9 blocks
==5897==    still reachable: 194,073 bytes in 2,929 blocks

(almost all of the reachable stuff is RPC/asio/boostthreads)