public function recordEventFinish()
    {
        if (is_null($this->history)) {
            return;
        }

        $this->history->time_to_run = $this->calculateRunTime();
        $this->history->exitcode = $this->exitcode;
        $this->history->output = $this->retrieveOutput();
        $this->history->save();
    }