QUARTERDECK – the after weather deck. Literally a deck which ran 1/4th of the ships’ length from the stern. Traditionally, the position of command where the vessels’ master/captain would control the ship. He could best judge the wind and sea direction from there, adjusting his sails and course accordingly.
Respect is always payed (salute or come briefly to attention/doff cap) to the quarterdeck when boarding or leaving a ship as an acknowledgment of the Captain’s authority (the Crown), however it has a more ancient history.
Sailors are a superstitious lot, and the ocean is a dangerous place, so they would erect a shrine to whichever god they hoped would protect them.
Of course, the most comfortable place on a sailing ship is at the stern, so that’s where they placed the shrine and would pay homage to it whenever they entered or left the ship. Interestingly, the vessel’s Master would also act as their god’s priest (mess with the Captain and you mess with god!) and this tradition has carried on to today. In particular, the performance of marriage or burial at sea.