Serialize the data for a close frame.

    This is the reverse of :func:`parse_close`.

def serialize_close(code: int, reason: str) -> bytes:
    """
    Serialize the data for a close frame.

    This is the reverse of :func:`parse_close`.

    """
    check_close(code)
    return struct.pack("!H", code) + reason.encode("utf-8")