{"record":{"id":"93d5e4597b5d0590","repo":"JosefNemec/Playnite","slug":"another-playnite-instance-didn-t-shutdown-in-time","errorCode":null,"errorMessage":"Another Playnite instance didn't shutdown in time.","messagePattern":"Another Playnite instance didn't shutdown in time\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"source/Playnite/App/PlayniteApplication.cs","lineNumber":1695,"sourceCode":"        }\r\n\r\n        private void WaitForOtherInstacesToExit(bool throwOnTimetout)\r\n        {\r\n            if (Process.GetProcesses().Where(a => IsProcessPlayniteProcess(a)).Count() > 1)\r\n            {\r\n                logger.Info(\"Multiple Playnite instances detected, waiting for them to close.\");\r\n                for (int i = 0; i < 10; i++)\r\n                {\r\n                    Thread.Sleep(500);\r\n                    if (Process.GetProcesses().Where(a => IsProcessPlayniteProcess(a)).Count() == 1)\r\n                    {\r\n                        break;\r\n                    }\r\n                    else if (i == 9)\r\n                    {\r\n                        if (throwOnTimetout)\r\n                        {\r\n                            throw new Exception(\"Another Playnite instance didn't shutdown in time.\");\r\n                        }\r\n                        else\r\n                        {\r\n                            logger.Warn(\"Another Playnite instance didn't shutdown in time.\");\r\n                        }\r\n                    }\r\n                }\r\n            }\r\n        }\r\n\r\n        public static bool IsProcessPlayniteProcess(Process process)\r\n        {\r\n            return process.ProcessName.StartsWith(\"Playnite.DesktopApp\") || process.ProcessName.StartsWith(\"Playnite.FullscreenApp\");\r\n        }\r\n\r\n        public abstract PlayniteAPI GetApiInstance(ExtensionManifest pluginOwner);\r\n        public abstract PlayniteAPI GetApiInstance();\r\n    }\r","sourceCodeStart":1677,"sourceCodeEnd":1713,"githubUrl":"https://github.com/JosefNemec/Playnite/blob/5911f4e964e628aa7a69c2030ab35101afa63067/source/Playnite/App/PlayniteApplication.cs#L1677-L1713","documentation":"Thrown (when throwOnTimeout is true) after the startup loop polls running Playnite processes 10 times at 500 ms intervals and still finds more than one. Playnite waits up to ~5 seconds for a prior instance to exit during a single-instance handshake; if it does not, this exception aborts startup.","triggerScenarios":"Launching Playnite while a previous instance is still shutting down (or hung) and remaining above the single-process threshold for >5 s, with throwOnTimeout enabled on the WaitForOtherInstances call.","commonSituations":"A crashed/hung prior Playnite process holds resources; slow shutdown due to a misbehaving extension holding a DB lock; system under heavy load delaying process exit; AV interfering with process enumeration.","solutions":["Manually end any lingering Playnite processes via Task Manager before relaunching.","Check for and disable/remove extensions that block shutdown (e.g. holding the database open).","Reboot to clear stuck processes if Task Manager cannot end them.","If calling the API, pass throwOnTimeout=false to log-and-continue instead of throwing."],"exampleFix":"// before\nPlayniteApplication.WaitForOtherInstances(throwOnTimetout: true);\n\n// after\nPlayniteApplication.WaitForOtherInstances(throwOnTimetout: false);","handlingStrategy":"validation","validationCode":"var stray = Process.GetProcesses().Where(PlayniteApplication.IsProcessPlayniteProcess).ToList();\nif (stray.Count > 1)\n{\n    foreach (var p in stray.Where(p => p.Id != Environment.ProcessId)) p.Kill();\n}\nPlayniteApplication.WaitForOtherInstances(throwOnTimetout: false);","typeGuard":null,"tryCatchPattern":"try { PlayniteApplication.WaitForOtherInstances(throwOnTimetout: true); }\ncatch (Exception e) when (e.Message.Contains(\"didn't shutdown\"))\n{ logger.Warn(e, \"Prior instance lingering; continuing.\"); }","preventionTips":["Pass throwOnTimeout=false to tolerate lingering instances when appropriate.","Ensure extensions release DB/handles promptly on shutdown.","Document that users may need to end hung Playnite processes before relaunch."],"tags":["startup","single-instance","process","playnite"],"backgroundTag":null,"analyzedSha":"5911f4e964e628aa7a69c2030ab35101afa63067","analyzedAt":"2026-08-13T17:38:25.713Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}