Change your preferences here.
Enemy Pokémon cannot switch out unless they have the ability Shadow Tag. Pokémon can also escape by using U-Turn or Baton Pass, or by holding the item Shed Shell.