Stop socket write failing if socket is closed