Fixes #8952 In5ebf5835b0we added a segment prune after flushing, to deal with deadlocks in shutdown. This means that calls that issue sync/flush-like ops "for-all", need to operate on a defensive copy of the list. Closes #8980 (cherry picked from commitce45ffdffb)