Repository: projectdiscovery/httpx (language: go)

Issue:
Clistats not stopped on runner close
### httpx version: v1.6.7

### Current Behavior:
I'm trying to use httpx as a library with stats enabled. I want to close one runner and open another but I get this error:
```
panic: pattern "/metrics" (registered at /go/pkg/mod/github.com/projectdiscovery/clistats@v0.0.20/clistats.go:123) conflicts with pattern "/metrics" (registered at /go/pkg/mod/github.com/projectdiscovery/clistats@v0.0.20/clistats.go:123):
/metrics matches the same requests as /metrics

goroutine 1 [running]:
net/http.(*ServeMux).register(...)
	/usr/local/go/src/net/http/server.go:2738
net/http.HandleFunc({0x135588d?, 0x10?}, 0x271fcc0?)
	/usr/local/go/src/net/http/server.go:2732 +0x86
github.com/projectdiscovery/clistats.(*Statistics).Start(0xc00e668680)
	/go/pkg/mod/github.com/projectdiscovery/clistats@v0.0.20/clistats.go:123 +0x6f
github.com/projectdiscovery/httpx/runner.(*Runner).prepareInput(0xc006320000)
	/go/pkg/mod/github.com/projectdiscovery/httpx@v1.6.7/runner/runner.go:488 +0x5a2
github.com/projectdiscovery/httpx/runner.(*Runner).RunEnumeration(0xc006320000)
	/go/pkg/mod/github.com/projectdiscovery/httpx@v1.6.7/runner/runner.go:713 +0x48c
```

### Expected Behavior:
No crash. The clistats server should be shutdown when .Close() is called on the runner.
In runner.go the Close() function looks like:
```go
func (r *Runner) Close() {
	// nolint:errcheck // ignore
	r.hm.Close()
	r.hp.Dialer.Close()
	r.ratelimiter.Stop()
	if r.options.HostMaxErrors >= 0 {
		r.HostErrorsCache.Purge()
	}
	if r.options.Screenshot {
		r.browser.Close()
	}
	if r.options.OnClose != nil {
		r.options.OnClose()
	}
}
```
It should include
```go
if r.options.ShowStatistics {
	runner.stats.Stop()
}
```

### Steps To Reproduce:
```go
package main

import "github.com/projectdiscovery/httpx/runner"
func main(){
	options := runner.Options{
		Methods:                   "GET",
		Threads: 1,
		ShowStatistics:true,
		InputTargetHost: []string{"http://google.com"},
	}
	options.ValidateOptions()
	httpxRunner, _ := runner.New(&options)
	httpxRunner.RunEnumeration()
	httpxRunner.Close()
	httpxRunner, _ = runner.New(&options)
	httpxRunner.RunEnumeration()
}
```
Running this will crash with this output:
```
./lol
https://google.com
panic: pattern "/metrics" (registered at /home/chieftan/go/pkg/mod/github.com/projectdiscovery/clistats@v0.0.20/clistats.go:123) conflicts with pattern "/metrics" (registered at /home/chieftan/go/pkg/mod/github.com/projectdiscovery/clistats@v0.0.20/clistats.go:123):
/metrics matches the same requests as /metrics

goroutine 1 [running]:
net/http.(*ServeMux).register(...)
	/usr/lib/go/src/net/http/server.go:2738
net/http.HandleFunc({0x15c8709?, 0x10?}, 0xc000075008?)
	/usr/lib/go/src/net/http/server.go:2732 +0x86
github.com/projectdiscovery/clistats.(*Statistics).Start(0xc000863780)
	/home/user/go/pkg/mod/github.com/projectdiscovery/clistats@v0.0.20/clistats.go:123 +0x6f
github.com/projectdiscovery/httpx/runner.(*Runner).prepareInput(0xc0008b81a0)
	/home/user/go/pkg/mod/github.com/projectdiscovery/httpx@v1.6.7/runner/runner.go:488 +0x5a2
github.com/projectdiscovery/httpx/runner.(*Runner).RunEnumeration(0xc0008b81a0)
	/home/user/go/pkg/mod/github.com/projectdiscovery/httpx@v1.6.7/runner/runner.go:713 +0x48c
main.main()
	/tmp/lol/lol.go:16 +0x125
```


Discussion / hints:
The `apiServer` in `runner.httpApiEndpoint` also needs to be shutdown if `options.HttpApiEndpoint` but `runner/apiendpoint.go` has no Close or Stop function right now 

Fix patch:
diff --git a/go.mod b/go.mod
index 8905f15d2..4a115be27 100644
--- a/go.mod
+++ b/go.mod
@@ -22,7 +22,7 @@ require (
 	github.com/pkg/errors v0.9.1
 	github.com/projectdiscovery/asnmap v1.1.1
 	github.com/projectdiscovery/cdncheck v1.1.0
-	github.com/projectdiscovery/clistats v0.0.20
+	github.com/projectdiscovery/clistats v0.0.21
 	github.com/projectdiscovery/dsl v0.1.7
 	github.com/projectdiscovery/fastdialer v0.2.1
 	github.com/projectdiscovery/fdmax v0.0.4
diff --git a/go.sum b/go.sum
index eb3abffd9..52121e956 100644
--- a/go.sum
+++ b/go.sum
@@ -224,6 +224,8 @@ github.com/projectdiscovery/cdncheck v1.1.0 h1:qDITidmJsejzpk3rMkauCh6sjI2GH9hW/
 github.com/projectdiscovery/cdncheck v1.1.0/go.mod h1:sZ8U4MjHSsyaTVjBbYWHT1cwUVvUYwDX1W+WvWRicIc=
 github.com/projectdiscovery/clistats v0.0.20 h1:5jO5SLiRJ7f0nDV0ndBNmBeesbROouPooH+DGMgoWq4=
 github.com/projectdiscovery/clistats v0.0.20/go.mod h1:GJ2av0KnOvK0AISQnP8hyDclYIji1LVkx2l0pwnzAu4=
+github.com/projectdiscovery/clistats v0.0.21 h1:8wQ6fwbEyGo3IFDa21P2NhxnkeDJA1xoocHypw/BFbI=
+github.com/projectdiscovery/clistats v0.0.21/go.mod h1:GJ2av0KnOvK0AISQnP8hyDclYIji1LVkx2l0pwnzAu4=
 github.com/projectdiscovery/dsl v0.1.7 h1:mPaHFPr2IMq69SjFGTt/DP8W5QeaGo+6lHqusnko2Qw=
 github.com/projectdiscovery/dsl v0.1.7/go.mod h1:pjBGO539itAgO+qD5PSXTcvRiF92tJKLzkA1aqCMwEQ=
 github.com/projectdiscovery/fastdialer v0.2.1 h1:or3QuGW1jlZKi+IRkwxShSAG/hgR+yamd52RqjaZ28Q=
diff --git a/runner/runner.go b/runner/runner.go
index 06ea14f2b..5579b1a67 100644
--- a/runner/runner.go
+++ b/runner/runner.go
@@ -672,6 +672,9 @@ func (r *Runner) Close() {
 	if r.options.Screenshot {
 		r.browser.Close()
 	}
+	if r.options.ShowStatistics {
+		_ = r.stats.Stop()
+	}
 	if r.options.OnClose != nil {
 		r.options.OnClose()
 	}


Test patch: