Generic exit function for iTerm2
In Terminal, the default setting for handling closed sessions is to leave the window open.

In Preferences > Profiles:



In iTerm2, the default is to close the window



If you disable that option in iTerm2, it should give you the behavior you're looking for.