Properly close the connection from the client

First try, a pure POC, to fix #15.