close wave_proc after termination to prevent accumulation of file handlers