Added config writing on exit.