remote_wait_for_cancel: move pending check before poll()

Otherwise it can still hang.