How to make rainbow ends fade out
One way to fix this is by placing the UVmap inside the texture space bounds :



then you can use the UV output directly in the ColorRamp input:



and here is the render :