prepareCommit followed by commit or rollback in case of exception; unlock the direcotry if close() throws an exception and the direcory is locked after that