Fix issue with #977 on state switches / properly clean up the signal listener