public function deactivateModule($namespace)
    {
        $namespace = Framework::prepareNamespace($namespace);

        // If the module isn't activated we have nothing to deactivate
        if (!isset($this->activatedModules[$namespace])) {
            return false;
        }
        
        // Load the module to deactivate it
        $namespace = Framework::prepareNamespace($namespace);
        $module = $this->getModule($namespace);

        // If the module isn't initialized it isn't active
        if ($module === false) {
            return false;
        }
        
        // Deactivate the module
        $module->deactivate();
        
        // Remove the module and save the module cache
        unset($this->activatedModules[$namespace]);
        unset($this->modules[$namespace]);
        $this->saveActivatedModules();
        
        return true;
    }