title: Delete tensorflow checkpoint and event files after training
body: <p>After training and evaluating a custom tensorflow estimator, I would like to delete all the files that it saves - the checkpoint files, the event files, the eval folders, etc. - from within the same script. I am trying to do this by using shutil.rmtree on the directory that holds all the files; however, it keeps throwing this error:</p>
  
  <p>Traceback (most recent call last):
    File "C:\Users____\AppData\Local\Continuum\anaconda3\lib\weakref.py", line 548, in <strong>call</strong>
      return info.func(*info.args, **(info.kwargs or {}))
    File "C:\Users____\AppData\Local\Continuum\anaconda3\lib\tempfile.py", line 797, in _cleanup
      _shutil.rmtree(name)
    File "C:\Users____\AppData\Local\Continuum\anaconda3\lib\shutil.py", line 494, in rmtree
      return _rmtree_unsafe(path, onerror)
    File "C:\Users____\AppData\Local\Continuum\anaconda3\lib\shutil.py", line 384, in _rmtree_unsafe
      _rmtree_unsafe(fullname, onerror)
    File "C:\Users____\AppData\Local\Continuum\anaconda3\lib\shutil.py", line 384, in _rmtree_unsafe
      _rmtree_unsafe(fullname, onerror)
    File "C:\Users____\AppData\Local\Continuum\anaconda3\lib\shutil.py", line 384, in _rmtree_unsafe
      _rmtree_unsafe(fullname, onerror)
    File "C:\Users____\AppData\Local\Continuum\anaconda3\lib\shutil.py", line 393, in _rmtree_unsafe
      onerror(os.rmdir, path, sys.exc_info())
    File "C:\Users____\AppData\Local\Continuum\anaconda3\lib\shutil.py", line 391, in _rmtree_unsafe
      os.rmdir(path)</p>
  
  <p>OSError: [WinError 145] The directory is not empty: 'C:\Users\____\AppData\Local\Temp\4\tmpfuioqj79\search_1\fold_1\eval'</p>
  
  <p>My understanding is that shutil.rmtree will remove the directory and all of its contents, and, when I use shutil.rmtree from a separate script after the script that creates and trains the models is finished, it works fine. Therefore, my I'm guessing that tensorflow is still using the files/directory. I cannot find anything in the estimator or saver documentation that would suggest I need to manually close something after training with the estimator implementation.</p>
  
  <p>Anyone have any idea how to delete these files from the same script that performs the training and evaluation?</p>
  
  <p>Edit: After looking through all the files that are being used by python processes, it looks like it's only the event files, not the checkpoint files, that are still in use.</p>