Correctly handle listener stop.

Fix #1