Socket close fixes