Fixed crash when exiting the client.