To debug the issue further, I wrote a simple Java based HTTP client. This client would open a socket to the nginx server, write the request line (GET / HTTP/1.1), write the host header, write the Connection:close header and commit the request. While committing the write the CRLF character twice.
In this setup, I tested by having a proxy pass to www.google.com and not having a proxy pass (nginx servers the default index.html.
If there is no proxy pass, nginx never gives a 499 status code. Even if I do Socket.shutdownOutput(), nginx give a valid 200 response. This is irrespective of the Connection header (keepalive/close).
If there is proxy pass, I get a valid response if I don't do Socket.shutdownOutput(). But if I do Socket.shutdownOutput(), I get 499 irrespective of Connection header (keepalive/close). This implies that nginx is treating client's Socket.shutdownOutput() as client closing the connection despite all data being written to the socket.