Add a safe guard when destroying the Client