Assignments to @sleeping should be inside the begin...rescue block, otherwise there's a race condition with shutdown, and the Interrupt exception could escape poll_sleep.