Fairly simple and straightfoward, you should create a logout() function that closes the connectiong between the client and tibia so we can create scripts that xlog under certain circumstances.