fixed bug with ending polling.