Correct socket closing