Properly protect macro arguments
This should fix most of those crashes when quitting

Hide window immediately when quitting.
Wait for all clients to call -disconnect before allowing the main loop to terminate.
Ignore all received data when terminating (since our window has been destroyed by then).