Finalizes logs and records rotation.