How to get Z-distance (not depth) from camera to object for every pixel in the frame?
The Camera Data node will give you a shader which will return the values you are looking for in the pixels of an image.

Here's a calibration scene. The camera is at World (0,0,1), the planes are at Z = 0, 1, 2, 3.



With this shader set-up, the pixel-value will be Z-component of the vector from the camera to the shading-point. ( You could also have shaded the planes using the Texture Coordinate node, in the Object space of the camera, and taken the Z component of that)



The nodes in the 'Illustration Only' frame are there to bring the lengths into a 0-1 range.. you wouldn't use those. Ensure the render output is linear, (set the Color Management to 'Raw'), and save to a floating-point format, probably, as you say, EXR, (in which case, as @susu has commented, color transforms will be bypassed.)