Refactor: move out print_stat and exit_handler of dmn