Adding some guard code to `stopListening`