diff --git a/core/includes/module.inc b/core/includes/module.inc
index 9be96cd..0617858 100644
--- a/core/includes/module.inc
+++ b/core/includes/module.inc
@@ -627,33 +627,40 @@ function module_disable($module_list, $disable_dependents = TRUE) {
     $module_list = array_keys($module_list);
   }
 
-  $invoke_modules = array();
+  // Filter invalid module names.
+  $module_list = array_filter($module_list, function ($module) {
+    return module_exists($module);
+  });
 
   $module_config = config('system.module');
   $disabled_config = config('system.module.disabled');
   foreach ($module_list as $module) {
-    if (module_exists($module)) {
-      module_load_install($module);
-      module_invoke($module, 'disable');
-      $disabled_config
-        ->set($module, $module_config->get($module))
-        ->save();
-      $module_config
-        ->clear("enabled.$module")
-        ->save();
-      $invoke_modules[] = $module;
-      watchdog('system', '%module module disabled.', array('%module' => $module), WATCHDOG_INFO);
-    }
-  }
+    module_load_install($module);
+    module_invoke($module, 'disable');
+
+    // Invoke hook_module_disable before actually disabling the module so we
+    // can still invoke hooks of the module to be disabled.
+    module_invoke_all('module_disable', $module);
+
+    $disabled_config
+      ->set($module, $module_config->get($module))
+      ->save();
+    $module_config
+      ->clear("enabled.$module")
+      ->save();
 
-  if (!empty($invoke_modules)) {
     // Refresh the module list to exclude the disabled modules.
     system_list_reset();
     module_implements_reset();
     entity_info_cache_clear();
-    // Invoke hook_modules_disabled before disabling modules,
-    // so we can still call module hooks to get information.
-    module_invoke_all('modules_disabled', $invoke_modules);
+
+    watchdog('system', '%module module disabled.', array('%module' => $module), WATCHDOG_INFO);
+  }
+
+  if (!empty($module_list)) {
+    // Invoke hook_modules_disabled() after all modules have been disabled.
+    module_invoke_all('modules_disabled', $module_list);
+
     _system_update_bootstrap_status();
     // Update the kernel to exclude the disabled modules.
     drupal_container()->get('kernel')->updateModules(module_list());
diff --git a/core/modules/system/lib/Drupal/system/Tests/Module/EnableDisableTest.php b/core/modules/system/lib/Drupal/system/Tests/Module/EnableDisableTest.php
index e73ace9..48cd595 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Module/EnableDisableTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Module/EnableDisableTest.php
@@ -179,8 +179,9 @@ function assertSuccessfulDisableAndUninstall($module) {
     $this->assertText(t('The configuration options have been saved.'), 'Modules status has been updated.');
     $this->assertModules(array($module), FALSE);
 
-    // Check that the appropriate hook was fired and the appropriate log
+    // Check that the appropriate hooks were fired and the appropriate log
     // message appears.
+    $this->assertText(t('hook_module_disable fired for @module before it got disabled.', array('@module' => $module)));
     $this->assertText(t('hook_modules_disabled fired for @module', array('@module' => $module)));
     $this->assertLogMessage('system', "%module module disabled.", array('%module' => $module), WATCHDOG_INFO);
 
diff --git a/core/modules/system/tests/modules/system_test/system_test.module b/core/modules/system/tests/modules/system_test/system_test.module
index ee67964..dd9f087 100644
--- a/core/modules/system/tests/modules/system_test/system_test.module
+++ b/core/modules/system/tests/modules/system_test/system_test.module
@@ -196,6 +196,17 @@ function system_test_modules_enabled($modules) {
 }
 
 /**
+ * Implements hook_module_disable().
+ */
+function system_test_module_disable($module) {
+  if (state()->get('system_test.verbose_module_hooks')) {
+    if (module_exists($module)) {
+      drupal_set_message(t('hook_module_disable fired for @module before it got disabled.', array('@module' => $module)));
+    }
+  }
+}
+
+/**
  * Implements hook_modules_disabled().
  */
 function system_test_modules_disabled($modules) {
