Avoid leak when stopping server

If accept fails, e.g., because the server is no longer listening the
connection object is not terminated and it results in a memory leak:
connection -> handler -> connection.
Merge pull request #334 from aydany/master

Avoid leak when stopping server