The attorney for the city or city and county commencing the proceedings has the right to withdraw said proceedings or to dismiss the same as to one or more of said defendants or as to one or more parcels of land, without prejudice, at any stage of the proceedings, and the petitioner shall pay the costs thereof.