add shut down mechanism to client. finish the lifecycle~
need to clean up the code