Added a custom exit function