How and why Caenorhabditis elegans uses distinct escape and avoidance regimes to minimize exposure to noxious heat