Any character that melees will automatically break follow. Any channeling ability will also automatically break follow, ie aimed shot.

Hunters automatically melee if attack is turned on and the target gets into melee range and will automatically go back to using a ranged weapon as soon as the target is far enough away.

I don't think you can turn off the auto melee of hunters.