If your rectangles are polylines, you have to explode them first, as polylines don't work with trim tools.
Then, with the trim tool, select the limiting line first, it's color will change.
Now click on the line to trim, outside of the horizontal rectangle, and the part inside the rectangle will be deleted.
You can trim multiple entities to the selected limiter. Use right click or ESC to cancel the trim tool and select another limiter.
The smaller line looks like it could be deleted, if not, you have to use trim too.
At least, if needed, you can join the rectangle to a polyline again.