properly clear state listener