From IslamQA.info

The ‘iddah of a woman whose husband has died is four months and ten days, because Allaah says (interpretation of the meaning):

“And those of you who die and leave wives behind them, they (the wives) shall wait (as regards their marriage) for four months and ten days”

[al-Baqarah 2:234]

This period begins when the husband dies, and ends when the time is over, whether the wife adheres to the rulings on mourning or not, and whether she knows of her husband’s death or not. When four months and ten days have passed from the time of his death, then her ‘iddah ends.

Ibn Qudaamah (may Allaah have mercy on him) said (8/93): The scholars are unanimously agreed that the ‘iddah of a free Muslim woman who is not pregnant is four months and ten days from the death of her husband, whether the marriage had been consummated or not, and whether she was an adult who had reached puberty or very young and had not yet reached puberty. That is because Allaah says (interpretation of the meaning): “And those of you who die and leave wives behind them, they (the wives) shall wait (as regards their marriage) for four months and ten days.” 

The Prophet (peace and blessings of Allaah be upon him) said: “it is not permissible for a woman who believes in Allaah and the Last Day to mourn for any one who dies for more than three days, except for a husband, four months and ten days.” Agreed upon.

It says in Fataawa al-Lajnah al-Daa’imah (20/421): The woman whose husband dies must observe ‘iddah for four months and ten days if she is not pregnant. Allaah says (interpretation of the meaning):“And those of you who die and leave wives behind them, they (the wives) shall wait (as regards their marriage) for four months and ten days”. That starts from the date of death. If a woman deliberately does not observe mourning then she is sinning, and she has to repent and seek forgiveness.

It also says (20/481): The ‘iddah for one whose husband dies is four months and ten days immediately following the death, and until giving birth if she is pregnant.

Thirdly:

A woman who is observing iddah following her husband’s death may go out of the house during the day to meet her needs, such as dealing with government procedures if there is no one who can do that for her. But at night she should not go out except in cases of necessity.

Ibn Qudaamah (may Allaah have mercy on him) said in al-Mughni (8/130): The woman who is observing ‘iddah may go out and do errands during the day, whether she is divorced or widowed, because of the report narrated by Jaabir who said: My maternal aunt was thrice divorced and she went out to harvest her palm trees. A man met her and told her not to do that. She mentioned that to the Prophet (peace and blessings of Allaah be upon him) and he said: “Go out and harvest your palm trees; perhaps you will give some of it in charity or do some good.” Narrated by al-Nasaa’i and Abu Dawood.

Mujahid narrated: Some men were martyred on the day of Uhud and their wives came to the Messenger of Allaah (peace and blessings of Allaah be upon him) and said: O Messenger of Allaah, we feel scared at night; can we stay in the house of one of our number, then in the morning we will go to our own houses? The Messenger of Allaah (peace and blessings of Allaah be upon him) said: “Chat together in the house of one of your number, then when you want to sleep, each one should go to her own house.” She does not have the right to stay overnight anywhere but in her own house, or to go out at night, except in cases of necessity, because night is a time of suspicion, unlike the day, which is the time when people go about their errands and earn a living, and buy what they need.

It says in Fataawa al-Lajnah al-Daa’imah (20/440): The basic principle is that a woman should mourn in the house of her husband where he died, and she should not go out except in cases of need or necessity, such as going to the hospital if she falls sick or buying what she needs from the marketplace such as bread and the like, if she does not have anyone who can do that.

Full article here.