OOME fix when client not authenticated

When a client fails to authenticate, the client is not shut down correctly and its resources (e.g. threads) are not released. Which eventually leads to an OutOfMemoryError.