Yes, the will is still valid, since who inherits under a will is completely independent of marital status, and a person can leave part or all of their estate to an ex-spouse. Whomever is named as beneficiary inherits, regardless of marital status. To remove the ex spouse, someone would gave to revoke, revise, or replace the will so the ex-spouse is no longer the beneficiary.