Refactor the RPC thread into a shutdown-able class.