Add atomic close tracking. Closes #370.