Added a signal handler which closes the listener correctly

Ideally we'll tell our clients we're shutting down.
Let's nicely close our connection in our client when we're told to stop

And fixed a memory leak.
How about we set this to NULL after we've freed it