free the task *after* calling closeCond and closeMutex