In Unity, sometimes you can't stop coroutines. To fix this, you must start and stop coroutines with strings. It's weird because you can start them by just calling the method name. But that won't let you stop it. This is what works:

Example:

    public void StartCoroutine()
    {
        StartCoroutine("TheCoroutine");
    }

    public void StopCoroutine()
    {
        StopCoroutine("TheCoroutine");
    }


    IEnumerator TheCoroutine()
    {
        while (true)
        {
            // do stuff

            yield return new WaitForSeconds(1f);
        }
    }