Put together the functions to free the raw socket and the SSL connection.

That way we have moved everything possible out of main function.

Signed-off-by: Thiago Farina <tfarina@chromium.org>