add an option to provide the exit function