   (-write-byte conn windowid)
   (-write-byte conn inventorytype)
   (-write-string8 conn windowtitle)
-  (-write-byte conn numberofslots)
-)
+  (-write-byte conn numberofslots))
+
+(defn write-packet-closewindow [conn {windowid :windowid}]
+  (-write-byte conn (:closewindow packet-ids))
+
+  (-write-byte conn windowid))
 
 
 ; Writing Wrappers -----------------------------------------------------------------

    :soundeffect          (write-packet-soundeffect conn payload)
    :newinvalidstate      (write-packet-newinvalidstate conn payload)
    :openwindow           (write-packet-openwindow conn payload)

    )
  (flushc conn))

        :newinvalidstate           (read-packet-newinvalidstate conn)
        :thunderbolt               (read-packet-thunderbolt conn)
        :openwindow                (read-packet-openwindow conn)
        :closewindow               (read-packet-closewindow conn)

        :else (str "UNKNOWN PACKET TYPE: " packet-id)
        ))
