Terminal.app also closes the window when the shell exits if you change a setting: Settings -> Profiles -> Shell -> When the shell exits -> Close the window