Nothing to it. Once all activity across the session has stopped , simply shut down the TCP connection. At the NBT level, there are no special messages to send when closing the session.