public async Task Stop()
        {
            try {
                if (IsStarted)
                {
                    IsStarted = false;
                    RemoveEventHandlers();

                    Log("Sending '{0}' message.", Methods.ShutdownName);
                    await jsonRpc.InvokeAsync(Methods.ShutdownName);

                    Log("Sending '{0}' message.", Methods.ExitName);
                    bool success = await jsonRpc.InvokeAsyncWithTimeout(Methods.ExitName, 1000);

                    if (!success)
                    {
                        Log("Timed out sending '{0}' message.", Methods.ExitName);
                    }
                }
            } catch (Exception ex) {
                Log("Stop error: {0}", ex);
            } finally {
                Dispose();
            }
        }