Shutdown management

clean_list contains function write_to_files
rewritten it clearer
files are closed in AnalogGraphThreads