FYI, you can also do this:

```
var listenerKey = olMap.on('click', onMapClick);
olMap.getLayers().on('remove', function(layersEvent) {
  if (layersEvent.getElement() === olLayer) {
    olMap.unByKey(listenerKey);
  }
});
```

This may be convenient, as you don't have to keep a reference to the listener function.