private static void UnhandledExceptionFancyHandler(Exception e) { if (!System.Windows.Application.Current.Windows.OfType<Window>().Any(x => x.IsLoaded && x.IsVisible)) { throw new Exception(); } DpiAwareWindow.OnFatalError(e); }