When a macOS High Sierra Terminal shell is ended using the
exit command the Bash shell history is saved and can be recalled in subsequent shell sessions. However, if the shell is ended by closing the Terminal tab or window, the shell history will not be saved. How can the shell history also be saved when closing a Terminal tab?
Presumably the problem relates to the fact that the trap set in
trap shell_session_update EXIT) is not triggered when closing a tab. Is there a signal that could be trapped when closing a Terminal tab?