Correcting correlation functions for redshift-dependent interloper contamination