fix internal usage of `.on('end', ...)`