workaround for closing socket before  event fires
checking for _destroy flag
adding check for socket sync

switching undefined check to null
Merge #522 r=@jiahuang: Slow http writes during HW busy times

We can run into issues like this when we have HW interrupts messing with our timing:
```
// us writing
writing POST /photo HTTP/1.1
Host: 192.168.128.250:3000
Transfer-Encoding: chunked


4

test

// note that right here we're supposed to have a 0\r\n\n
// however we only do that once the 'finish' event is called on the socket. 
// my guess is that we don't do this here because Tessel is busy with HW things from a camera

// got this response from the express server
HTTP/1.1 200 OK
X-Powered-By: Express
Content-Type: text/html; charset=utf-8
Content-Length: 7
Date: Fri, 03 Oct 2014 07:44:08 GMT
Connection: keep-alive

done

// right now the socket is closed
// but we finally catch the 'finish' event
// without this PR we would try to write 0\r\n\n here and get a writable stream error
```

Technically this problem can also be circumvented if people wait for the 'end' event on the request before sending a response, but I think very few people are going to do that.