It shall be lawful for any municipal corporation or board of commissioners having control of any improvement district within a municipal corporation, or any work completed by any district, to appropriate and use any funds recovered in litigation or for operating expenses for the purpose of paying off any bonded indebtedness of the district when the funds are not needed for the operating expenses of the district.