Handles Ctrl+C and sigint to close data file before quitting