code: protected TaskBase endOfProcessDetected(ProcessInstance processInstance, Audit currentAudit) {
  		TaskBase ret = null;
  		TaskBase currentTask = getCurrentTask(processInstance);
  		ProcessInstanceUtils.clearQueue(processInstance, TaskStatus.DONE);
  		currentAudit.setStatus(TaskStatus.DONE);
  		// End of process can mean just the end of a handler process.
  		{
  			List<Audit> audits = findHandlerTasks(processInstance);
  			for (Audit audit : audits) {
  				TaskBase taskBase = getTask(audit);
  				audit.setHandler(false);
  				if (taskBase instanceof TaskTry) {
  					TaskTry taskTry = (TaskTry)taskBase;
  					if (taskTry.getTimeoutValue() > -1) {
  						// we ended a handler that had a timeout.
  						// That means we need to cancel the timeout.
  						getWorkflowDAO().removeDeferredEvent(processInstance,taskTry);
  					}
  					TaskBase nextTask = taskTry.getNextTask(processInstance);
  					nextTask.loadTask(processInstance);
  				}
  				if (taskBase instanceof TaskIf) {
  					TaskIf taskIf = (TaskIf)taskBase;
  					TaskBase nextTask = taskIf.getNextTask(processInstance);
  					nextTask.loadTask(processInstance);
  				}
  				ret = getCurrentTask(processInstance);
  				break;
  			}
  
  		}
  		// If this is a subprocess then tickle the parent.
  		tickleParentProcess(processInstance,TaskStatus.DONE);
  		if (ret == currentTask) {
  			processInstance.setStatus(TaskStatus.DONE);
  		}
  		getWorkflowDAO().mergeProcessInstance(processInstance);
  		getWorkflowDAO().flush();
  		getWorkflowDAO().refreshProcessInstance(processInstance);
  		return ret;
  	}
docs: If this is just the end of the handler then return the next task after the handler
  If it is the end of the whole process then return null.
  @param processInstance
  @param currentAudit
  @return TaskBase