stencil shadows and fog

why stencil shadows not affected with the fog(look to the picture)?

how can i solve this problem?

That is because your shadowing algo is rather dumb - sou simply blend your screen picture with dark-gray rectangle, isn’t it? And fog applies depending on the screen-distance. So to do this correctly, you should think a little bit.
You may write rather simple fragment program, which takes screen depth, converts it to distance and simulates fog, and use it when full-screen blend pass occurs.
Or you may cancel with full-screen blending and make double-pass, first one is Z-fill pass with ambient lighting, stencil-test disabled, second pass doesn’t modifies depth, makes diffuse lighting, and stencil-test enabled.
Or you may implement smth your own.