Socket improvements

Most important fix here is to stop processing events if socket is closed during error on handle_read or handle_write. It also seems like previous check for closed socket should not be checking for method parameter fd.

Calling socket.shutdown() was inspired by this:
http://engineering.imvu.com/2014/03/06/charming-python-how-to-actually-close-a-socket-by-calling-shutdown-before-calling-close/