fix bug when user terminate a task