How to close a pipe with a perfect hemisphere?
Using the bevel tool is a simple way to do this. First remove all of the edge loops on the endcap so you just have a single n-gon like this:



Note that I scaled the cylinder to give it an elliptical profile and skewed the face so that it is not perpendicular to the axis of the cylinder. I did this because this is how it appears to me in your picture. If you make your endcap perpendicular to the profile axis you will get a cleaner (more spherical) result. 

Be that as it may, I used the Bevel tool which is located in the menu: Mesh > Edges > Bevel with the settings shown on the bottom left of the following image:



Using 8 segments achieves a well rounded result, although as I previously mentioned, the dome shape is distorted because of the angle of the face in respect to axis of the profile. I found that the "Depth" setting worked the best in this situation because I was able to extend the bevel very close to the convergence point without getting overlap. You may want to experiment with the settings to get what you want.

Addendum:
Just to clarify what I mean about getting a cleaner, more spherical result by making the end cap perpendicular to the profile axis, here is a comparison: