public function close($which = null)
    {
        if (! $this->buffers->count()) {
            throw new LogicException('It is not possible to close a never opened block.');
        }
        list($buffer, $name) = $this->buffers->pop();
        if (! is_null($which) && $which !== $name) {
            throw new InvalidArgumentException(
                "Please close blocks in order: you need to close other block(s) before \"{$which}\"."
            );
        }
        $output = $buffer instanceof Block ? $buffer->close() : '';

        return $output;
    }