Unlock the job, mark it as finished, update the status, add the results for every job's task. job - the job object. It'll be saved to the backend with the provided properties. callback - f(err, job) callback will be called with error if something fails, otherwise it'll return the updated job using getJob.
function finishJob(job, callback) {
            if (!jobs[job.uuid]) {
                return callback(new e.BackendResourceNotFoundError(sprintf(
                  'Job with uuid \'%s\' does not exist', job.uuid)));
            } else if (jobs[job.uuid].execution !== 'running' &&
                jobs[job.uuid].execution !== 'canceled') {
                return callback(new e.BackendPreconditionFailedError(
                  'Only running jobs can be finished'));
            } else {
                if (job.execution === 'running') {
                    job.execution = 'succeeded';
                }
                var info = jobs[job.uuid].info;
                job.runner_id = null;
                jobs[job.uuid] = clone(job);
                if (info) {
                    jobs[job.uuid].info = info;
                }
                if (typeof (job.locks) !== 'undefined') {
                    delete locked_targets[job.uuid];
                }
                return callback(null, job);
            }
        }