Fixed a bug that occurred when the task changes its state to finished