As someone who was contracting we always had notice periods in contracts. Let’s not forget it works both ways and contractors are more often than not the first to go.
When I was freelancing, I would have a Master Service Agreement that spelled out the "rules of engagement" and the actual work was in a Statement Of Work that lasted roughly 3 months. Gave each party the ability to pull the rip cord