Al-Baqarah - 2:240

وَالَّذِينَ يُتَوَفَّوْنَ مِنكُمْ وَيَذَرُونَ أَزْوَاجًا وَصِيَّةً لِّأَزْوَاجِهِم مَّتَاعًا إِلَى الْحَوْلِ غَيْرَ إِخْرَاجٍ فَإِنْ خَرَجْنَ فَلاَ جُنَاحَ عَلَيْكُمْ فِي مَا فَعَلْنَ فِيَ أَنفُسِهِنَّ مِن مَّعْرُوفٍ وَاللّهُ عَزِيزٌ حَكِيمٌ
[2:240]
And those of you who die and leave wives behind, (make) a bequest in favor of their wives of maintenance for a year without turning (them) out, then if they themselves go away, there is no blame on you for what they do of lawful deeds by themselves, and Allah is Mighty, Wise.
Those of you who die and leave widows should bequeath for their widows a year's maintenance and residence; but if they leave (The residence), there is no blame on you for what they do with themselves, provided it is reasonable. And Allah is Exalted in Power, Wise.
(In the case of) those of you who are about to die and leave behind them wives, they should bequeath unto their wives a provision for the year without turning them out, but if they go out (of their own accord) there is no sin for you in that which they do of themselves within their rights. Allah is Mighty, Wise.