Fix error on deleting threads

Change-Id: I7bf9d87a44877c4c4fc9d66e2401445ef1c961cc