you never need to manually assign a particular number to a scriptJob as the return value of the scriptJob is it's job number, so you can just store this and use it to kill the job. Just take a look at the examples in the scriptJob MEL doc.
you can also parent the scriptJob to some UI, so when the UI is closed, the scriptJob is automatically killed. You could always create a hidden window and kill it to kill the parented scriptJob without knowing it's number...