How would I run it so I could stop it outside of the game??
Open notepad and run the command, so the output is sent to notepad.
After you stop the command, run a command containing the following:
Write '[Blue] NUM1:{STATE_KEYSTATE:NUM1} NUM7:{STATE_KEYSTATE:NUM7} NUM+:{STATE_KEYSTATE:NUM+}' to log
If there's a "1" after any of those, the corresponding key is still pressed.
I replicated and tested your command, running it while sending the output to notepad doesn't leave any keys pressed after forcibly stopping the command.
I don't have Elite:Dangerous to test with, but it's possible the game is either interfering with, or not recognizing the key release.