We can't easily support using SetParticles with trails, other than to modify existing particles.
Any use of SetParticles that sets more or less particles back to the system than it previously had, will cause problems with the trails data, because it is stored separately from the ParticleSystem.Particle data.
Instead, it should be possible to set the same particles back, but with remainingLifetime set to -1 for any particles you wish to remove.