7.x common.inc drupal_exit($destination = NULL)

Performs end-of-request tasks.

In some cases page requests need to end without calling drupal_page_footer(). In these cases, call drupal_exit() instead. There should rarely be a reason to call exit instead of drupal_exit();


$destination: If this function is called from drupal_goto(), then this argument will be a fully-qualified URL that is the destination of the redirect. This should be passed along to hook_exit() implementations.

20 calls to drupal_exit()
ajax_get_form in includes/ajax.inc
Gets a form submitted via #ajax during an Ajax callback.
contact_personal_form in modules/contact/contact.pages.inc
Form constructor for the personal contact form.
contact_site_form in modules/contact/contact.pages.inc
Form constructor for the site-wide contact form.
dashboard_show_block_content in modules/dashboard/dashboard.module
Ajax callback: Displays the rendered contents of a specific block.
dashboard_show_disabled in modules/dashboard/dashboard.module
Ajax callback: Shows disabled blocks in the dashboard customization mode.

... See full list


includes/common.inc, line 2801
Common functions that many Drupal modules will need to reference.


function drupal_exit($destination = NULL) {
  if (drupal_get_bootstrap_phase() == DRUPAL_BOOTSTRAP_FULL) {
    if (!defined('MAINTENANCE_MODE') || MAINTENANCE_MODE != 'update') {
      module_invoke_all('exit', $destination);


colan’s picture

glantucan’s picture

I inherited a drupal site with a custom module with several endpoints to send POST requests. All of them just end with a call to drupal_json_output($response). No drupal_exit() or exit() at all. Is this all right?. What is happening when you do not call drupal_exit()?