I am writing a datalogger program that uses an infinite loop to log data from the parallel port to a file. I can use Ctrl-C to exit the program but the file handle is not released. Is there a way to use the Esc-key or an F-key to break the loop to close files and end the program systematically?