This is an attempt to fix the situation described by https://reviews.llvm.org/D104207#2826290 and PR41508.
See sequence of operations leading to the bug in https://reviews.llvm.org/D104207#3004689
We ensure that the Latch is completely "free" before decrementing the number of TaskGroupInstances.
clang-tidy: warning: invalid case style for variable 'lock' [readability-identifier-naming]
not useful