Strange behavior when killing cmd


i’m trying to create a program that switches coins mining based on current difficulty and coin price.
and it works verry good atm, but when I try to kill the cmd.exe process and start a new process in order to mine the hassrate will go down by allot.
does somebody know how this happens?
my best gues is that I kill the wrong process and the miner is still running