Close connection properly and add Connection:close to headers