Update captiveportal.inc

Release unused pipeno when client is already authenticated.

Bug #3062
Put the fix to be more generic to prevent any other leak possible in the long run. Fixes #3062