envoyd: properly close the pipe