Fix: stop server thread when exiting chat