pause before closing socket in case of errors