This is a windows app. (Good point.)
One solution that comes to mind would go like this:
1. before you enter the loop that reads the port, create/open a named file mapping.
2. set the first byte in the file mapping to a value that indicates "continue" looping.
3. poll that value in the loop, if it isn't the "continue" value then break out of the loop.
the second step is to create a simple - and completely independent - console application that opens the named file mapping (of course, the name has to match) and overwrites the "continue" value found in the mapping.
It only takes a few lines of code to implement that.
HTH.