Particle system destroy

Is there any way to destroy a particle system after its done because the game crashes? This is my code:

    if(playerInput > 0)
    {
     ParticleSystem a = Instantiate(particles,LeftRocket.position,LeftRocket.rotation);
        
    }
    else if(playerInput < 0)
    {
     ParticleSystem a = Instantiate(particles, RightRocket.position, RightRocket.rotation);
        
    }
    if (particles)
    {
        if (!particles.IsAlive())
        {
            Destroy(a);
        }
    }
}

I attache this script called ParticleAutoDestruct.cs on the particle system prefab. Using this you wont have to check the particle system in the input script either.

using UnityEngine;
using System.Collections;

public class ParticleAutoDestruct : MonoBehaviour {

private ParticleSystem ps;

// Use this for initialization
void Start () {
	ps = gameObject.GetComponent<ParticleSystem>();
}

// Update is called once per frame
void Update () 
{
	if(ps)
	{
		if(!ps.IsAlive())
		{
			Destroy(gameObject);
		}
	}

}
}