Oh I think I see what you're saying now.. you want a way to terminate without loss of data?
PHP Code:
sw1 = new StreamWriter("csharplow.txt");
sw2 = new StreamWriter("csharphigh.txt");
Invoking the constructor for a StreamWriter counts as an open.
Do your calculations, start your threads, etc..
then
PHP Code:
Console.WriteLine("Press Q to Quit and Save");
do {
Console.Write(": ");
str = Console.ReadLine();
} while(str != "q");
// Kill threads
sw1.Close();
sw2.Close();
That way you always close them correctly before exit.