fixed race condition on close before we finish reading