Fix thread safety issue when closing Selector
@tarcieri Can this fix be merged or does it need additional work? This could cause deadlocks when calling close, not sure if that's how you want to approach it? Another idea would be just to set closed to true and wakeup the event loop. Then the loop could cleanup it's own stuff instead of having shutdown do that.
@dbussink not sure why the build is breaking but it seems unrelated. Overall this looks good to me. Guess I'll go ahead and merge it and see if I can figure out the build failures.