implement leave and close in client