Submarines and "Defenseless" Transports in Axis and Allies
You played the right way.

Basically, the turn continues until 1) all the defending forces are destroyed, or 2) all the attacking forces are destroyed or 3) the attacker elects to retreat. 

The defender cannot retreat. The exception is submarines, which can submerge (and retreat) if they get the right rolls.

Earlier on, you might have taken at least one transport as a casualty (8 for the transport, 6 for e.g. two infantry units, 14 in total) to save your battleship (15), the unit that has the best chance (going forward) to fight back. Instead, when you sacrificed your battleship, you doomed your transports because they can't fight back.