Collect, apply modifiers, and triangulate meshes before export, without touching the original mesh
Bmesh from object.
See How do I get a mesh data-block with modifiers and shape keys applied in Blender 2.8?  Can use the evaluated mesh and look at loop_triangles or with a bmesh and call the bmesh triangulate operator. In both cases no new data need be added to file.
The two answers show how to get the evaluated mesh as either a bmesh or an evauated mesh.  In either case there would appear little need to bother with a context manager to use the with statement.

Result of running on two selected subsurfed default cubes, creating one joined and triangulated to export
Here is an example that creates a joined and triangulated bmesh from all the selected mesh objects.
Just as with multiple calls to bm.from_mesh(...) can be used to read multiple meshes into one bmesh, can do same for bm.from_object.
On each &quot;read&quot; the new vertices are transformed by the objects matrix world.
To demonstrate result, a new mesh object is created and added to scene, whereas the exporter can simply re format the bmesh data.
import bpy
import bmesh
context = bpy.context

meshobs = [o for o in context.selected_objects if o.type == 'MESH']

dg = context.evaluated_depsgraph_get()

bm = bmesh.new()

for o in meshobs:
    n = len(bm.verts)
    bm.from_object(o, dg)
    bmesh.ops.transform(
            bm,
            verts=bm.verts[n:],
            matrix=o.matrix_world,
            )
    
bmesh.ops.triangulate(
        bm,
        faces=bm.faces,
        )
        
# new object to test
me = bpy.data.meshes.new(&quot;TriExportTest&quot;)
bm.to_mesh(me)
ob = bpy.data.objects.new(&quot;TriExportTest&quot;, me)
context.collection.objects.link(ob)

World or Object Coordinates?
Note the created bmesh above will have its vertices use the global coordinates of the input meshes. And an identity matrix world (no transform)  To more closely emulate the join operator, by using object space of the active object
Save and calculate inverse of matrix world of active object.
mw = context.active_object.matrix_world
mwi = mw.inverted()

then in the bmesh transform operator
    matrix = mwi @ o.matrix_world

and finally assign the matrix world to the joined object
ob = bpy.data.objects.new(&quot;TriExportTest&quot;, me)
ob.matrix_world = mw