You can purchase FloodSafe washing machine hoses which have an internal valve which will automatically shut-off the flow of water due to bursts, breakage, or rupture and are supposed to prevent catastrophic flood damage.
Here is one example:
https://www.amazon.com/Armour-Washin.../dp/B013TMFQVS