Close connection when writing is done, fixes timeout for nginx.