Fix the orphan thread issue