Listen to 'finish' event before writing the response body

Otherwise we may miss the event being emitted.