<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def kill(self, name):
 # type: (str) -> None """ Kills the given component :param name: Name of the component to kill :raise ValueError: Invalid component name """

        if not name:
            raise ValueError("Name can't be None or empty")

        with self.__instances_lock:
            try:
                # Running instance
                stored_instance = self.__instances.pop(name)

                # Store the reference to the factory context
                factory_context = stored_instance.context.factory_context

                # Kill it
                stored_instance.kill()

                # Update the singleton state flag
                factory_context.is_singleton_active = False
            except KeyError:
                # Queued instance
                try:
                    # Extract the component context
                    context, _ = self.__waiting_handlers.pop(name)

                    # Update the singleton state flag
                    context.factory_context.is_singleton_active = False
                except KeyError:
                    raise ValueError(
                        "Unknown component instance '{0}'".format(name)
                    )