Shared state of a TaskGroup. Held behind an Arc so each task can
keep a Weak reference back to the group and remove itself on
completion, without forcing callers to wrap the group in an Arc.
Lives inside the spawned task. If the task or its callback panics, it
signals cancel_flag and removes the task from the group, so cancel
does not wait forever.
Removes a task from its group. Detach instead of dropping the handler,
so the task is not cancelled from within itself. If cancel already
took it out, this is a no-op.