config: improve finalization