diff --git a/src/nvim/terminal.c b/src/nvim/terminal.c index c985665b4f..0047a8c789 100644 --- a/src/nvim/terminal.c +++ b/src/nvim/terminal.c @@ -583,9 +583,6 @@ void terminal_close(Terminal **termpp, int status) FUNC_ATTR_NONNULL_ALL { Terminal *term = *termpp; - if (term->destroy) { - return; - } #ifdef EXITFREE if (entered_free_all_mem) { @@ -596,6 +593,10 @@ void terminal_close(Terminal **termpp, int status) } #endif + if (term->destroy) { // Destruction already scheduled on the main loop. + return; + } + bool only_destroy = false; if (term->closed) {