Destructive finishing up after execution stopped.
433931
def cleanup(self):
        
        for actor in self.actors:
            if actor.skip:
                continue
            actor.cleanup()
        super(ActorHandler, self).cleanup()
90927
public function stop()
    {
        if ($this->pid) {
            exec('kill ' . $this->pid, $output, $ret);
            if ($ret !== 0) {
                throw new Exception('Error stopping build-in server.');
            }
            $this->pid = null;
        }
    }
394701
def finish(self, status, response):
        """"""

        self.response = binascii.hexlify(response).decode('utf-8')
        self.status = status
        self.runtime = monotonic() - self._start_time
683707
function (err, length, data) {
    if (err) {
      if (self.autoClose) {
        self.destroy()
      }
      self.emit('error', err)
    }
    self.push(data)
    // self.once('finish', self.close)
  }
1204417
public void finish() throws IOException
    {
        ensureNotFinished();
        flushBufferedData();
        compressedBuffer[MAGIC_LENGTH] = (byte) (COMPRESSION_METHOD_RAW | compressionLevel);
        writeIntLE(0, compressedBuffer, MAGIC_LENGTH + 1);
        writeIntLE(0, compressedBuffer, MAGIC_LENGTH + 5);
        writeIntLE(0, compressedBuffer, MAGIC_LENGTH + 9);
        assert MAGIC_LENGTH + 13 == HEADER_LENGTH;
        out.write(compressedBuffer, 0, HEADER_LENGTH);
        finished = true;
        out.flush();
    }
823809
function (done) {

      // Clean up fixtures.
      _.each(fileFixtures, function (f) {
        f.unlinkSync();
      });

      // Clean up directory w/ test output.
      fsx.removeSync(outputDir.path);

      // Teardown the HTTP server.
      server.close(done);
    }
1212917
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) {
		// Stop view stopwatch
		stopStopwatch();

		// Remove location
		threadLocation.remove();
	}
827340
def cleanup(self):
        """"""
        if self.process is None:  # Process wasn't running yet, so nothing to worry about
            return
        if self.process.poll() is None:
            log.info("Sending TERM to %d", self.process.pid)
            self.process.terminate()
            # Give process a second to terminate, if it didn't, kill it.
            start = time.clock()
            while time.clock() - start < 1.0:
                time.sleep(0.05)
                if self.process.poll() is not None:
                    break
            else:
                log.info("Sending KILL to %d", self.process.pid)
                self.process.kill()
        assert self.process.poll() is not None
813188
def _finalize(self):
        """"""
        if self.status in ['running', 'halt']:
            if self.verbose > 0:
                print_('\nSampling finished normally.')
            self.status = 'ready'

        self.save_state()
        self.db._finalize()
573046
static synchronized void destroy() {
        if (debuggable()) {
            hasInit = false;
            LogisticsCenter.suspend();
            logger.info(Consts.TAG, "ARouter destroy success!");
        } else {
            logger.error(Consts.TAG, "Destroy can be used in debug mode only!");
        }
    }
35138
def end_task(self):
        '''
        
        '''
        self.progress(self.task_stack[-1].size)
        self.task_stack.pop()
346533
private function cleanupFinishedProcesses()
    {
        if ( time() < ( $this->cleanupLastTime + $this->cleanupInterval ) )
        {
            return;
        }

        $processes = count( ezpContentPublishingProcess::fetchProcesses( ezpContentPublishingProcess::STATUS_FINISHED ) );
        if ( $processes > 0 )
        {
            //Remove all objects at once
            // this is required as the MySQL connection might be closed anytime by a fork
            try
            {
                eZDebug::writeNotice( "ASYNC:: removing processes entries marked as STATUS_FINISHED in database.");
                $db = eZDB::instance();
                eZDB::setInstance( null );
                $deleteBefore = time() - $this->cleanupAgeLimit;
                $definition = ezpContentPublishingProcess::definition();
                $processTable = $definition['name'];
                $db->query( "DELETE from ". $processTable. " WHERE status =".  ezpContentPublishingProcess::STATUS_FINISHED. " AND finished < ". $deleteBefore );
                $this->cleanupLastTime = time();
            }
            catch( eZDBException $e ) 
            {
                // Do nothing, this will be retried until the DB is back up
            }
        }
    }
1048041
function (invoiceitem, cb) {

		Invoiceitem.destroy(invoiceitem.id)
	    .exec(function (err, destroyedInvoiceitems){
	      if (err) return cb(err);
	      if (!destroyedInvoiceitems) return cb(null, null);
	      Invoiceitem.afterStripeInvoiceitemDeleted(destroyedInvoiceitems[0], function(err, invoiceitem){
	      	cb(err, invoiceitem);
	      });
	    });
	}
1191298
def die(self):
        """"""
        if self.process:
            _log(self.logging,
                 'Stopping {0} server with PID: {1} running at {2}.'
                     .format(self.__class__.__name__, self.process.pid,
                             self.check_url))

            self._kill()
515381
private void cleanup() { // d623593
        final boolean isTraceOn = TraceComponent.isAnyTracingEnabled();

        if (isTraceOn && tc.isEntryEnabled())
            Tr.entry(tc, "cleanup");

        synchronized (ivRemoteAsyncResultReaper) {
            if (ivAddedToReaper) { // d690014
                // d690014.3 - The call to remove will remove the result from the
                // reaper and then call unexportObject itself.
                this.ivRemoteAsyncResultReaper.remove(this);
            } else {
                unexportObject();
            }
        }

        if (isTraceOn && tc.isEntryEnabled())
            Tr.exit(tc, "cleanup");
    }
979445
def after_processing(eng, objects):
        """"""
        super(InvenioProcessingFactory, InvenioProcessingFactory)\
            .after_processing(eng, objects)
        if eng.has_completed:
            eng.save(WorkflowStatus.COMPLETED)
        else:
            eng.save(WorkflowStatus.HALTED)
        db.session.commit()
209680
@Override
    public final void after() {
        log.debug("after {}", containerShortId);
        try {
            dockerLogs.close();
            ContainerState state = dockerClient.inspectContainer(container.id()).state();
            log.debug("{} state {}", containerShortId, state);
            if (state.running()) {
                if (builder.stopOptions().contains(StopOption.KILL)) {
                    dockerClient.killContainer(container.id());
                    log.info("{} killed", containerShortId);
                } else {
                    dockerClient.stopContainer(container.id(), STOP_TIMEOUT);
                    log.info("{} stopped", containerShortId);
                }
            }
            if (builder.stopOptions().contains(StopOption.REMOVE)) {
                dockerClient.removeContainer(container.id(), DockerClient.RemoveContainerParam.removeVolumes());
                log.info("{} deleted", containerShortId);
                container = null;
            }
        } catch (DockerException | InterruptedException e) {
            throw new IllegalStateException(e);
        }
    }