modified groupByUntil include the key of the group in the closings function.