All praise is due to Allah. May Allah's peace and blessings be upon the Messenger of Allah, his family, and companions.
To proceed:
A number of scholars were of the view that a woman who is in her waiting period after the death of her husband should stay in her house in which her husband died. They used as proof for that Allah's statement: " Do not turn them out of their [husbands'] houses, nor should they [themselves] leave [during that period]" [at-Talaq: 1]. A proof which is more explicit than the verse in indicating that it is compulsory for a woman to stay in her husband house is what was transmitted in the books of hadith on the authority of Furay'ah bint Maalik (may Allah be pleased with her) that she said, " My husband went out to pursue some slaves of his and he found them at the outskirts of Al-Qadum, and they killed him. I was informed of his death while I was in a remote home of my family. I told the Messenger of Allah (peace be upon him) about this and I said, "The news of my husband's death came to me while I was in a remote home of my family. He did not leave expenditure, nor did I inherit any wealth, and the house that we were staying in is not his. It would be better if I went to stay with my family and brothers." The Prophet said, "You may go where you want." When I went out of the mosque, he called me, or he sent someone to call me. He said, "Stay in your house until the appointed time passes." She said, " So I spent four months and ten days in that house." She also said, " 'Uthman sent someone to ask me about this, and I told him, and he ruled according to it."
Even though some scholars have doubted the authenticity of this hadeeth, ibn al-Qayyim (may Allah have mercy on him) responded to the criticisms and said, "These criticisms do not necessitate rejecting this authentic, explicit hadeeth which was accepted by 'Uthman and the senior Sahaba. "
That is the ruling which is established for the woman who is in her waiting period after the death of her husband. Thus, she should stay at her house if there is no need for her to leave house because of unavoidable reasons. However, if she faces extraordinary difficulty in staying at her house, it is permissible for her to move and go wherever she wants according to the majority of the scholars from the Hanafites, the Malikites, and the Hambalites. The rulings which were binding upon her in her first house will be binding upon her in the house that she moves to.
Her temporary leaving of the house, if she needs to do that is permissible according to the majority of the scholars. However, she must only sleep in her house. Needs for which she is permitted to leave her house include going out to seek a livelihood, as indicated by the hadeeth of Furay'ah which was discussed above. Another reason is loneliness caused by staying alone. Thus, it permissible for her to go out and interact with her peers. However, if she wants to sleep, she should go to her house. The Hambalite jurists differentiated between going out for a need, and going out during the day, and going out at night. They say, "She may go out during the day for a need, and she must not go out at night except for a necessity." As far as I know there is no proof from the Sunnah which supports this differentiation. I asked our Shaykh ibn Baz (may Allah have mercy on him) about this, and he answered me by saying that there is no basis for that. So, the correct opinion is that which was held by the majority of the scholars that there is no differentiation between day and night in this regard. And Allah knows best.