windows: Run close callbacks after polling for i/o

Master version of #814