It’s the attacker’s option whether he wants to stop and fight the sub or move on through. If he attacks the sub then the destroyer must end its movement in that sea zone for the turn.
Last paragraph on Page 11 of the rulebook states that “An enemy submarine and/or transport does not block any of your units’ movement, nor does it prevent loading or offloading that sea zone. As the moving player you have the option of attacking an enemy submarine that shares a sea zone with you.”