Fix an unexpected IllegalStateException from a selector loop when a user cancels a connection attempt

- Fixes #1986