I have a module that creates a custom entity. In the module.install file, in hook_uninstall, I remove any entity records.
Running drush pmu results in an error because there are entity records. It turns out that the hook_uninstall, which deletes the records along with performing other cleanup, is not firing before the error is thrown.
DrupalCoreExtensionModuleUninstallValidatorException: The following reasons prevent the modules from being uninstalled: There[error] is content for the entity type: My Entities. <a href="/admin/modules/uninstall/entity/my_module">Remove my_entities entities</a>. in /var/www/web/core/lib/Drupal/Core/Extension/ModuleInstaller.php:437 Stack trace: #0 /var/www/web/core/lib/Drupal/Core/ProxyClass/Extension/ModuleInstaller.php(91): DrupalCoreExtensionModuleInstaller->uninstall(Array, true) #1 phar:///usr/local/bin/drush8/commands/core/drupal/environment_common.inc(187): DrupalCoreProxyClassExtensionModuleInstaller->uninstall(Array) #2 phar:///usr/local/bin/drush8/commands/core/drupal/pm.inc(79): drush_module_uninstall(Array) #3 phar:///usr/local/bin/drush8/commands/pm/pm.drush.inc(1265): _drush_pm_uninstall(Array) #4 phar:///usr/local/bin/drush8/includes/command.inc(422): drush_pm_uninstall(my_module') #5 phar:///usr/local/bin/drush8/includes/command.inc(231): _drush_invoke_hooks(Array, Array) #6 phar:///usr/local/bin/drush8/includes/command.inc(199): drush_command('my_module') #7 phar:///usr/local/bin/drush8/lib/Drush/Boot/BaseBoot.php(67): drush_dispatch(Array) #8 phar:///usr/local/bin/drush8/includes/preflight.inc(67): DrushBootBaseBoot->bootstrap_and_dispatch() #9 phar:///usr/local/bin/drush8/includes/startup.inc(465): drush_main() #10 phar:///usr/local/bin/drush8/includes/startup.inc(369): drush_run_main(false, '/', 'Phar detected. ...') #11 phar:///usr/local/bin/drush8/drush(114): drush_startup(Array) #12 /usr/local/bin/drush8(10): require('phar:///usr/loc...') #13 {main}