Insulating basement rim joist cavities
Cutting rigid foam really won’t be much better than what you have unless you seal the boards with foam.

I would spray foam around the penetrations first. I use a closed-cell foam that sticks well and can be sprayed on then it expands to ~1-1/2” but  that is a small space and the stuff I use really doesn’t store well. It covers ~100sf per can or so.

I might try with the big box stores foam in small cans around the pipes and wires then cut some rigid board fit in place and seal the seams. This would be the most cost effective way. If the rigid foam was cut and ready to put in it could be done with 1 can.