fix bug that monitor thread cannot be terminated