Handle terminate status from poller. And better logic for engine loop

Whouldn't be this better logic in engine loop?