You have discovered a deceptively difficult problem all games have. You need to use these commands.
The Most Important Commands You Need:
Exclude Object On
(makes the object not get drawn anymore)
Exclude Object Off
(makes the object get drawn again)
Rule 1: You cannot use both of these commands on the same object without having a SYNC happen in between. So if you are sloppy and hide everything then try to set stuff to be shown that won't work.
You got to dream up a clever way of knowing when objects are on screen (intended to be visible) and when they are off screen (intended to be not visible). Then you use the above commands to add/remove the objects from the rendering pipeline.
So maybe you can do some math and calculate when an object is too far away for the camera to see it, then exclude them. Don't forget to reverse this when they become visible again.