let add_at_exit f = 
  at_exit_functions := f :: !at_exit_functions