clean up files. add listener to wait for key presses to finish