diff --git a/src/nvim/terminal.c b/src/nvim/terminal.c index 13005b263e51eb..016e1a5a97b7d4 100644 --- a/src/nvim/terminal.c +++ b/src/nvim/terminal.c @@ -262,6 +262,9 @@ Terminal *terminal_open(buf_T *buf, TerminalOptions opts) void terminal_close(Terminal *term, int status) { if (term->closed) { + if (status == -1 && !term->refcount) { + terminal_destroy(term); + } return; }