Shutdown socket writes before close

Calling shutdown(2) with SHUT_WR before close(2) ensures that a FIN
packet is sent before any RST packet. Doing so ensures that clients
and proxies get a clean shutdown signal when the server terminates the
connection while an upload is pending.

Fix #872
yeah, the only problem I see is how to handle the normal case: all have been received then we close. In that case we don't need to wait for the final EOF since it will block.