I'm lost.
Are you saying that you're using a shell where the string
%{http_code} sometimes expands to one of the strings
200,
%{200},
%200, or
{200}?
If so, which one?
And, if so, isn't there something equivalent to the
test utility in that shell that you can use to determine whether or not
%{http_code} expands to the undesired string before you start the
curl in the background instead of trying to kill it off after it has been started?
What operating system and shell are you using?
What shell will you be using to try to detect whether or not these bad forms of background jobs are running.?
Doesn't the operating system you're using have a
ps command that can be used to display the command line arguments being used by running processes?