Add a null check to TaskView object before the dismissTask() method is called