(regarding the Verse): 'If any of you dies and leaves wives behind,' That was the period of the 'Iddah which the widow was obliged to spend in the house of the late husband. Then Allah revealed: And those of you who die and leave wives should bequeath for their wives a year's maintenance and residence without turning them out, but if they leave, there is no blame on you for what they do of themselves, provided it is honorable (i.e. lawful marriage) (2.240) Mujahid said: Allah has ordered that a widow has the right to stay for seven months and twenty days with her husband's relatives through her husband's will and testament so that she will complete the period of one year (of 'Iddah). But the widow has the right to stay that extra period or go out of her husband's house as is indicated by the statement of Allah: 'But if they leave there is no blame on you,... ' (2.240) Ibn `Abbas said: The above Verse has cancelled the order of spending the period of the 'Iddah at her late husband's house, and so she could spend her period of the 'Iddah wherever she likes. And Allah says: 'Without turning them out.' 'Ata said: If she would, she could spend her period of the 'Iddah at her husband's house, and live there according to her (husband's) will and testament, and if she would, she could go out (of her husband's house) as Allah says: 'There is no blame on you for what they do of themselves.' (2.240) 'Ata added: Then the Verses of inheritance were revealed and the order of residence (for the widow) was cancelled, and she could spend her period of the 'Iddah wherever she would like, and she was no longer entitled to be accommodated by her husband's family.
Narrated Zainab bint Um Salama
When Um Habiba bint Abi Sufyan was informed of her father's death, she asked for perfume and rubbed it over her arms and said, "I am not in need of perfume, but I have heard the Prophet (ﷺ) saying, "It is not lawful for a lady who believes in Allah and the Last Day to mourn for more than three days except for her husband for whom the (mourning) period is four months and ten days."