private void OnPluginStopped(PluginInstance pluginInstance,
                                     bool crashed = false)
        {
            if (IsDisposed || pluginInstance.Status == PluginStatus.Stopped)
            {
                return;
            }

            if (crashed)
            {
                // Notify user about crash
                LogTo.Information($"{pluginInstance.Denomination.CapitalizeFirst()} {pluginInstance.Metadata.PackageName} has crashed");
            }
            else
            {
                LogTo.Information($"{pluginInstance.Denomination.CapitalizeFirst()} {pluginInstance.Metadata.PackageName} has stopped.");
            }

            foreach (var interfaceType in pluginInstance.InterfaceChannelMap.Keys)
            {
                UnregisterChannelType(interfaceType, pluginInstance.Guid);
            }

            _runningPluginMap.TryRemove(pluginInstance.Guid, out _);

            pluginInstance.OnStopped();
        }
        private void OnPluginStopped(PluginInstance pluginInstance)
        {
            if (IsDisposed || pluginInstance.Status == PluginStatus.Stopped)
            {
                return;
            }

            bool crashed = false;

            try
            {
                if (pluginInstance.Process?.HasExited ?? false)
                {
                    crashed = pluginInstance.Process.ExitCode != 0;
                }
            }
            catch
            {
                /* ignored */
            }

            LogTo.Information($"{pluginInstance.Denomination.CapitalizeFirst()} {pluginInstance.Metadata.PackageName} "
                              + $"has {(crashed ? "crashed" : "stopped")}");

            foreach (var interfaceType in pluginInstance.InterfaceChannelMap.Keys)
            {
                UnregisterChannelType(interfaceType, pluginInstance.Guid, false);
            }

            _runningPluginMap.TryRemove(pluginInstance.Guid, out _);

            pluginInstance.OnStopped();
        }