<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 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")