close sockfd when exception occurs