--- src/frame.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) --- src/frame.c +++ src/frame.c 2024-02-14 08:27:16.356238553 +0000 @@ -2259,7 +2259,11 @@ delete_frame (Lisp_Object frame, Lisp_Ob if (terminal->reference_count == 0 && (terminal->type == output_x_window || terminal->type == output_pgtk)) - terminal->reference_count = 1; + { + const char *delterm = getenv ("GTK_DELTERM"); + if (delterm) + terminal->reference_count = 1; + } #endif /* USE_X_TOOLKIT || USE_GTK */ if (terminal->reference_count == 0)