Clean up code to avoid thread race conditions on GC exit

On Ctrl-Q and Ctrl-W close events, ensure the TrainStops if it is running and in the Computrainer stop() method, clean up the thread and wait for it.  This avoids closing GC while the CT threat is still running and ensures all timers and files are closed properly.