trq-1887 Don't call thread cancel on an invalid threadid