def METHOD_NAME(f):
    """Decorator to close gRPC stream.
    Args:
        f (func): The function to decorate
    Returns:
        wrapper: wrapper of the decorator
    """
    def wrapper(*args):
        """Wrapper function, checks context state to close stream.
        Args:
            *args (list): All arguments provided to the wrapped function.
        Yields:
            object: Whatever the wrapped function yields to the stream.
        """
        def closed(context):
            """Returns true iff the connection is closed.
            Args:
                context (object): the connection to check
            Returns:
                bool: whether the connection is closed
            """
            return context._state.client == 'closed'
        context = args[-1]
        for result in f(*args):
            yield result
            if closed(context):
                return
    return wrapper