Fix errors thrown from socket shutdown on some systems.