Add proper finalization