Originally this was a custom called 'toshikomori' (also referred as toshigomori) in which the head of a family shut himself away in the shrine of the ujigami (a guardian god or spirit of a particular place in the Shinto religion) from the night of New Year's Eve until the morning of New Year's Day to offer prayers.
元々は「年蘢り」（としこもり、としごもり）と言い、家長が祈願のために大晦日の夜から元日の朝にかけて氏神の社に蘢る習慣であった。