'End of environment context'

def __exit__(self, exc_type, exc_value, tb):

    ret = self.handle_exception(exc_type, exc_value, tb)
    self.update_build_from_container_state()
    client = self.get_client()
    try:
        client.kill(self.container_id)
    except DockerAPIError:
        pass
    try:
        log.info('Removing    container    %s', self.container_id)
        client.remove_container(self.container_id)
    except DockerAPIError:
        log.error(LOG_TEMPLATE.format(project=self.project.slug, version=self.version.slug, msg="Couldn't    remove    container"), exc_info=True)
    self.container = None
    self.build['state'] = BUILD_STATE_FINISHED
    log.info(LOG_TEMPLATE.format(project=self.project.slug, version=self.version.slug, msg='Build    finished'))
    return ret
