CCTest: fix potential error
Solve thread shutdown on close. Rework collection close logic.