SHrug...speeding at 30 knots when new fandagled sonar picks you up and a Depth charge drops on you ? Slow motion yard dart.
I don’t know if the B-24’s had them, but Grumman TBM’s operating on ASW patrols were armed with a crude acoustic homing-torpedo.
Also, the Tenth Fleet (US) and the RN were monitoring all German radio traffic. If a sub sailed, they probably knew before, or slightly after, it left the pen. The sub would have to sail underneath allied air patrols who were alerted to look for that particular sub. The sub that attempted to take war materials to Japan as Germany fell was nailed off the west African coast by a TBM using this technique.