How to disable permalinks to some custom post content?

When defining a custom post type with register_post_type() an array of arguments is passed. Set the public parameter to ‘false’ to prevent generation of permalinks, as well as other associated actions (search, nav, et al).

Using the example from the WP Codex:

function codex_custom_init() {
    $args = array(
      'public' => false,
      'label'  => 'Books'
    );
    register_post_type( 'book', $args );
}
add_action( 'init', 'codex_custom_init' );

https://codex.wordpress.org/Function_Reference/register_post_type