How do I stop a local function using another function?

I have a local function calling a module script coroutine inside of it. I want to end the local function as well as the module script coroutines from another function. But the local functions and the coroutines seem to carry on when I call the coroutine again but for a different purpose

Have you tried using coroutine.close?