Depends on the room....
Our master bedroom is large and receives a lot of natural light and the closet is the entire length of the wall with sliding doors. The side walls of the closet are the same walls as our bedroom, so it was natural to keep on painting. The back wall of the closet could be anything since it is hardly seen, but we already had emptied the closet so why not paint it the same. It looks fantastic! (We have a medium-dark blue violet on all the walls and "ultra pure white" trim and ceiling....with a very large West-facing window, so it doesn't look dark at all.)
In our DD's bedroom, her closet is basically a 2x3 annex with a narrow door. Her bedroom walls are grass green on the bottom and sky blue on top. There was no reason to continue it into the tiny closet. I painted her closet bright white top to bottom and that is perfect for such a tiny space. She is 9 years old now and we are discussing adding purple flowers to her closet walls for fun.
Our family office has a sliding doors type closet that isn't the whole wall. Those doors are often open, so we painted the closet the same as the room (medium red-violet) with "ultra pure white" trim and ceiling. We have a custom shelving unit (Ikea Ivar) in that closet and it is also "ultra pure white" along with the regular rod and shelf and the doors. With all that white, it is easy to see anything in that closet. The color is mostly seen on the sides and up high in the back.
Our linen closet is all white, but it is more like a cupboard than a closet.
Our living room closet is the same as the living room, which is a pale peachy-cream color. If we had painted the living room anything even just slightly darker, I would have painted that closet ultra pure white because it has no light source and is located such that it receives no natural light whatsoever.
Our project room (extra room on main level) has bright blue walls with ultra pure white trim and ceiling and too many darn doors to be a useful room. That closet is our only storage closet and goes under the stairs. It is an odd space and I'm not sure if it even has any regular paint on the walls. I may have painted the main closet portion when I originally painted the room, in which case it would be a bright white (same as DD's closet, not the ultra pure white). The other portion of the closet has had work done to the walls and I think just has primer at this point.
It was the end of an intense timeframe after a major flood and I told the painters to just do whatever they wanted that would match the existing color good enough. It is a closet and is hardly seen by anyone except us and we don't care. It was the only space in the flood zone that I didn't know the color on the walls or have a paint sample or anything to go on. The original color was Swiss Coffee (builder boring off-white), but who knows by this point.....