The prosecuting attorney shall not enter a nolle prosequi in any cause without leave of the court, on good cause shown, in open court. A nolle prosequi entered contrary to this section is invalid.