Fix file locking issues when deleting data