correctly destroy element when route is being changed