<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def remove_instance(self, instance):
 """Request to cleanly remove the given instance. If instance is external also shutdown it cleanly :param instance: instance to remove :type instance: object :return: None """

        # External instances need to be close before (process + queues)
        if instance.is_external:
            logger.info("Request external process to stop for %s", instance.name)
            instance.stop_process()
            logger.info("External process stopped.")

        instance.clear_queues(self.daemon.sync_manager)

        # Then do not listen anymore about it
        self.instances.remove(instance)