Handle shutdowns niclely in ruby 2.1.2

Ruby 2.1.2 seems to raise a Errno::ENOTSOCK instead of Errno::EBADF if a socket is closed while another thread is listening.