fix some bug with terminating in task_handler.erl