the captain of the German pocket battleship Admiral Graf Spee, Hans Langsdorff, did take his own life during the Battle of the River Plate in December 1939.
After a prolonged engagement with three British cruisers, the Exeter, Ajax, and Achilles, the Graf Spee sustained significant damage and was forced to seek refuge in the neutral port of Montevideo, Uruguay. However, fearing that his ship would be destroyed if he attempted to leave port and engage the British ships again, Langsdorff decided to scuttle the Graf Spee to prevent it from falling into enemy hands.
Before doing so, he ordered the crew to abandon ship and then committed suicide by gunshot. Langsdorff's decision to scuttle the ship and his subsequent suicide were seen by many in Germany as acts of heroism, and he was widely mourned as a national hero.