fixed race condition on close