Yes, dop2000 has a good suggestion there, and of the two solutions that's more elegant, as long as you don't need the enemies to spawn for some other reason.
The main difference between blocking new enemies from spawning, and randomly culling excess enemies, is how the enemies will be distributed in the play area.
If you randomly cull enemies, they will uniformly thin out as more are spawned, so that on average there will be a higher density near their spawn point and a lower density near the player, (which I assume they move towards).
Hard Spawn Limit
If you block new enemies from spawning, then a hole in the enemies will appear around the spawn point as they stop spawning, and the density of enemies near the player will stay unchanged.
Feathered Spawn Limit
There's also a sort of hybrid approach to limiting enemies, that might give you the best of both options, no culling of existing enemies, but with a smoother distribution of enemies.
If you want enemy spawning to thin out as you approach 350, so that they don't just stop spawning abruptly, you can randomly "feather" off the spawn-success-rate of the enemies as you near the limit.
For this you need a "soft" limit like 300, above which the thinning out begins
When an enemy tries to spawn, it will always succeed if the count is under 300, but if the count is over 300, there's only a random chance it will succeed.
This success chance will fade from 100% (when the count is exactly 300), down to 0% (when the count is 350).
So for example, at 325, half way from the hard limit (350) to the soft limit (300), the chance of success would be 50%.
at 340, which is 20% of the way from the hard limit (350) to the soft limit (300), the chance of success would be 20%.
To do this, find the event that spawns the enemies, and try adding the following condition,
Compare to general values (found in System object):
random( 300 , 350 )
is greater than
Now an enemy will only spawn if this random number between 300 and 350 is larger than the current enemy count. The larger the enemy count the less likely the random number will beat it.
So, if the count is 325, the random( 300 , 350 ) has a 50/50 chance of beating it.
If the count is 350, the random( 300 , 350 ) can never beat it.