Save Bash shell history also when closing Terminal tab
This drove me crazy for months until I read through /etc/bashrc_Apple_Terminal. trap shell_session_update HUP fixed it for me. Terminal appears to send SIGHUP to the shell whenever a tab is closed or the entire Terminal app is closed via Cmd-Q.