How do I stop a module from installing optional configuration, or make sure it's installed by the time I want to remove it myself?
Hmm, have you tried in the .profile file an hook_install_tasks?

Or maybe with the hook_install_tasks_alter.

/**
 * Implements hook_install_tasks_alter().
 */
function MODULE_install_tasks_alter(array &amp;$tasks, array $install_state) {
  $tasks['install_finished']['function'] = 'CALLBACK_post_install';
}


And deactivate the view in the callback.