remove listener at right time