Sorry I misunderstood before. What you want to achieve is possible in two ways. 1. Within Expyriment, by manually defining how to process control keys (e.g. ESC) in all wait functions you use: ``` def custom_process_control_keys(): expyriment.io.Keyboard.process_control_keys(quit_confirmed_function=convert_variables) # and then calling this explicitely as callback function in EVERY wait method in your code, e.g.: exp.keyboard.wait(callback_function=custom_process_control_keys, process_control_events=False) ``` 2. Independent of Expyriment, by registering an atexit function: ``` import atexit atexit.register(convert_variables) ``` Hope that helps!