You could break out the checking for the form close into its own function, then call that function in your Do..Until loops. Copy of your server code below with those changes:
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("VChat", 616, 438, 192, 124)
$Input1 = GUICtrlCreateInput("", 8, 8, 513, 25, $ES_READONLY)
$Button1 = GUICtrlCreateButton("Send", 528, 8, 75, 25)
GUICtrlSetState(-1, $GUI_DISABLE)
$Edit1 = GUICtrlCreateEdit("", 8, 40, 593, 385, BitOR($ES_AUTOVSCROLL,$ES_AUTOHSCROLL,$ES_READONLY,$ES_WANTRETURN,$WS_VSCROLL))
GUICtrlSetData(-1, "")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
TCPStartup()
$TCPListen = TCPListen(@IPAddress1, 80)
Func CheckForClose()
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
EndFunc
Func retrieveData()
Do
Local $TCPAccept = TCPAccept($TCPListen)
CheckForClose()
Until $TCPAccept <> -1
Do
Local $TCPRecv = TCPRecv($TCPAccept, 1000000)
CheckForClose()
Until $TCPRecv <> ""
GUICtrlSetData($Edit1, GUICtrlRead($Edit1) & $TCPRecv & @CRLF)
EndFunc
While 1
retrieveData()
WEnd
Run(@ScriptFullPath)