Add debug output in shutdown phase
Correctly handle EINTR for poll