protected function unregisterInstance($key, $name)
    {
        if ($this->hasOption($key)) {
            $instances = $this->getOption($key);

            if (($index = array_search($name, $instances)) !== false) {
                unset($instances[$index]);
                $this->setOption($key, $instances);
                $this->registerMetadataService();
            }
        }
    }