To exit the debugger, use the quit command (abbreviated q), or type an end-of-file character (usually Ctrl-D). If you do not supply expression, the debugger will terminate normally; otherwise, it will terminate using the result of expression as the error code.
An interrupt (often Ctrl-C) does not exit from the debugger, but rather terminates the action of any the debugger command that is in progress and returns to the debugger command level. It is safe to type the interrupt character at any time because the debugger does not allow it to take effect until a time when it is safe.