void (@NotNull Application instance, @NotNull Disposable parent) { Application old = ourApplication; Disposer.register(parent, () -> { if (old != null) { // to prevent NPEs in threads still running setApplication(old); } }); setApplication(instance); }