req.socket.on('close', () => console.log('Doing something with closed connection')) //or res.on('close', () => console.log('Doing something with closed connection'))