In my day (75-87), "berthing" compartment doors were not normally closed, unless General Quarters (GQ). That's the first thing sounded when hit by anything or an impending threat. IIRC, each door and hatch had a specific letter on it - X being always closed. Y being closed under certain circumstances. Z even less. Depends on the configuration of the particular ship's compartments. I could have the designations wrong, so I pinged the 2 best Navy guys on FR.
That said, once the McCain was hit they would go to automatic GQ which is broadcast over the entire ship which requires every door/hatch to be closed no matter the letter designation. There have been times that sailors had to be sacrificed to keep the ship from sinking and taking all down. Happened many times in WWII. Watch the movie, "Crimson Tide" where the Captain had to sacrifice some guys in the bilge bay to keep the sub from going down.
Thanks