<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:

def uninstall(self, plugin):
        ''' Uninstall plugins. Pass an instance to remove a specific plugin.
            Pass a type object to remove all plugins that match that type.
            Subclasses are not removed. Pass a string to remove all plugins with
            a matching ``name`` attribute. Pass ``True`` to remove all plugins.
            The list of affected plugins is returned. '''
        removed, remove = [], plugin
        for i, plugin in list(enumerate(self.plugins))[::-1]:
            if remove is True or remove is plugin or remove is type(plugin) \
            or getattr(plugin, 'name', True) == remove:
                removed.append(plugin)
                del self.plugins[i]
                if hasattr(plugin, 'close'): plugin.close()
        if removed: self.reset()
        return removed