def _generate_end_sequence(leds: int) -> bytes:
    """
    Generate a byte sequence, that, when sent to the APA102 leds, ends a
    led update message.

    :param leds: number of chained LEDs.
    :return: terminating byte sequence.
    """
    edges_required = ((leds - 1) if leds else 0)
    bytes_required = 0
    output = bytearray()

    # Each byte provides 16 clock edges, each LED except the first requires
    # one clock edge to latch in the newly sent data.

    if edges_required:
        bytes_required = (((edges_required // 16) + 1) if (edges_required % 16)
                          else edges_required // 16)
    for i in range(bytes_required):
        output.append(0x00)

    return bytes(output)