iTerm2 does not kill processes when tab is closed
I think it is supposed to be a feature instead of a problem. 

Generally, to kill a process or just exit the current shell session, you should not use "cmd+w" or click the close button of the window. Instead, you should use "ctrl-c" and "ctrl-d" respectively. 

Besides, the following facts may help you,


You can use "cmd+z" to fully restore a tab right after it is closed
The attached session and tasks keep run in background right after you close a tab. You can restore the tab at this point. But if you open a new tab using "cmd+t" now, the background session in the previously closed tab will be killed. 


So the "restorable tab closing" is a feature of iterm2, though quite confusing.