Sometimes when I'm testing an ArcPy script and it ends with exception, ArcMap is still holding locks to some temp files (I run my scripts through ArcMap).
I cannot run the script any more, because it cannot delete/overwrite the temp files and in the end I have to restart ArcMap to release the locks.
Is there a way to do in a more clever fashion?