In general, a person can bequeath their assets to whoever they want.
Many jurisdictions impose a duty to make allowance for the maintenance of the testator's spouse and any dependents (usually children but could be other people). A will that doesn't do that can often be successfully challenged so that such an allowance is made. This would include the spouse in your scenario and any dependent children.
Anyone with standing can bring a suit to have the will invalidated. Having standing will usually be limited to those people who would have normally expected to benefit if the testator had died intestate or anyone who was promised something in the will as part of a contract or by the law of equity. This would include the spouse and children in your scenario. Whether they would succeed would depend on the circumstances.
An action could be brought at any time before the relevant statute of limitations expires. However, anyone who is contemplating a challenge would be wise to do so as soon as possible - courts are reluctant to undo actions taken in good faith (such as by the will's executor) if they would harm innocent third parties (such as the will's named beneficiaries).