Added socket close code