There is a good movie about this story.
They were given no choice. Either they violate the law and end up arrested and scuttled, or thy return to open sea for a guaranteed sinking.
Actually it's even more interesting than that. Under the so-called "Cruiser Rules" the German ship couldn't leave a neutral port within a certain time period (I think it was 24-hours) of the departure of a ship from a hostile nation. The Brits had several merchant ships in Montevideo harbor and they were letting them leave one-at-a-time in order to prevent the Graf Spee's early departure. By this gambit the British consulate was attempting to 'hold' the Graf Spee in the harbor until more Naval Forces arrived.
The deception worked: Capt. Langsdorff was convinced that he was going to run into a British Battle Fleet instead of a few damaged light cruisers, and so he slipped anchor with a skeleton crew and scuttled the ship, much to the relief of the British sailors.
The Graf Spee -- damaged as she was -- constituted a superior force to the allied cruiser force. She had them outranged & outgunned bigtime.