Test from #2724 for listener cleanup.