Added clear_locks function to clean up stale lock files