The mayor said the drawn-out dismissal of his federal case made it “impossible” to mount a reelection campaign in time for the Democratic primary.