Taking care of a case where the task could have been popped after
hasTasks() > 0.