At any time, either the client or the server can terminate the service loop by sending a GOODBYE message. Technically, this message is not strictly necessary since both parties can simply pull the plug on the connection. However, a graceful exit procedure provides a way for both the client and server to wrap up their business in an orderly manner. When either the client or the server has received a GOODBYE message, the receiving party should finish up its business and then terminate the connection. Also, whichever side issued the GOODBYE message is obligated to not create any additional responsiblities for its partner. In other words, neither the client nor the server, after issuing a GOODBYE message, is allowed to send any additional messages. Only the receiver of the GOODBYE message is allowed to continue sending service loop messages, though it must do so for only a limitted time.
For example, suppose the server has received an instant message from an outside source, and before it can be processed and sent down to the intended client, that client sends a GOODBYE message. The server would not disconnect until after it has faithfully delivered the message to the client. The corrolary to this is that the client, even after sending the goodbye message, must wait for the server's disconnect, and while doing so, must also process additional messages received through the server. Wise client implementations will, of course, implement a timeout feature in case the server never actually fulfills its duty to disconnect. Likewise, good servers should not accept additional instant messages from outside sources after it has processed the client's GOODBYE message, but should instead deliver only the pending messages, disconnect as quickly as possible, and refuse any incomng messages from the client's partners.