Move exit functions to debug.c