HPCC-9253 Significant semaphore overhead in the unordered concat

Fix regressions from previous commit, related to incorrect output grouping,
and potential lockups.

Signed-off-by: Richard Chapman <rchapman@hpccsystems.com>
Merge pull request #5147 from richardkchapman/unordered-concat-fixes

HPCC-9253 Significant semaphore overhead in the unordered concat

Reviewed-by: Gavin Halliday <ghalliday@hpccsystems.com>