Fixes a bug with elementary ui.
Events were not unregistered when ui was destroyed.
Fixes #326.