Move ClientWrapper to heap, and close databases from appropriate thread

Previously the main thread was closing the databases. Now they are
closed in the bitshares thread.

Also, ClientWrapper is now heap allocated.