properly handle unready socket
allow stopping the event loop

this has the side-effect that the eventloop no longer
busy-waits when it is empty.