Properly kill a thread when Home Automation is stopped

Hi folks, I’m pretty new to HA (and to Python3 development too) and I’m trying to develop my first component. Basically, the idea is to connect this piece of hardware to Home Assistant: senic.com
having the new nuimo component get messages from the tool and write them into HA event bus.

The current work in progress prototype is here:

github.com/shaftoe/home-assista … s/nuimo.py

I’ve got a question though: what’s the correct way to tear down the polling thread when HA has been terminated? Currently I’m using hass.bus.listen_once with EVENT_HOMEASSISTANT_STOP (line 30) but maybe there’s a better way. Thanks!

Never mind, @pavoni on Gitter confirmed this is a good way to go, ref. components/switch/vera.py for a working example.
Thanks