tdb: fix locking unlocking error introduced in cleanup