Add remove() method and automatically close handler once all events are removed

This PR adds a `remove()` method to remove any previously set up events. Also, it automatically closes the handler once all events are removed.