I believe that torpedos have safety interlocks to prevent them from locking onto their launching submarine. In fact, one theory regarding the sinking of the USS Scorpion involves the captain turning the boat 180 degrees to disarm a torpedo that had accidently gone active onboard.
According to PBS Nova Program
Had Scorpion turned around, and if so, why? The Navy has a possible explanation, but keeps it secret for 25 years. Finally, in 1993, the Navy releases its findings. The most likely scenario, the Navy believes, begins when stray electrical current activates an on-board torpedo. The captain orders an immediate 180 degree turn, which he expects will trigger a safety mechanism and disarm the torpedo. Then the crew ejects the torpedo. But it doesn't disarm. The torpedo begins to search for a target.
I may have many faults, but being wrong ain't one of them. - Jimmy Hoffa