The board may enter into an agreement in accordance with Section 20585 for termination of a contract that has been in effect for at least five years with respect to local firefighters if the firefighting function of the contracting agency and local firefighters have been transferred to a district which participates in a county retirement system. The contract shall continue with respect to all employees of the contracting agency other than local firefighters.