Being at “close quarters,” meaning to be overwhelmed within a small space, is a naval term from the 1700s.
Merchant sailing ships laden with valuable cargo had their decks outfitted with four strong wooden barriers with musket holes to which they could retreat and continue to fight if they were boarded by pirates or privateers.
They referred to these desperate circumstances as fighting at “close quarters.”