Ответ 1
Да, есть "близкое событие" - фактически два из них.
Чтобы процитировать vim : help {event}:
Startup and exit
|VimEnter| after doing all the startup stuff
|GUIEnter| after starting the GUI successfully
|TermResponse| after the terminal response to |t_RV| is received
|VimLeavePre| before exiting Vim, before writing the viminfo file
|VimLeave| before exiting Vim, after writing the viminfo file
Вы после VimLeave -Event.
Рабочий пример выглядит следующим образом:
function! ResetTitle()
" disable vim ability to set the title
exec "set title t_ts='' t_fs=''"
" and restore it to 'bash'
exec ":!echo -e '\033kbash\033\\'\<CR>"
endfunction
au VimLeave * silent call ResetTitle()
Кроме того, вы можете использовать v: dying, чтобы обнаруживать аномальные случаи выхода.