Correctly handle closing on remote for socketclient and add an identity client helper