motion tracking - is there a way to automatically clear tracks after they leave the frame?
I don't think there is an automatic way. 

You could try  changing the Correlation or Margin settings to make a tracker fail earlier, so that it stops and doesn't continue tracking with errors on the edge of frame.


Otherwise

Go to the frame where you have the last accurately tracked item and press delete forward (or back if you are tracking backwards).



Another way to deal with elements on the edge of frame (or when an object is temporarily blocked) is to offset the tracker, so that you can use other elements to continue tracking.

See: Joining 2D tracking markers with an offset

Blender has great tracking tools, but they do require a lot of work and manual and constant supervision. 

Keep in mind that you don't need a large number of tracking points (at least 8 for sure), but what matters is that the tracking is accurate. There are times where more tracking points can also be detrimental for the camera solution.

If you haven't done already read: 

How can I get better results when doing camera motion tracking?