Require a valid con before calling terminate

If get_connection returns null, e.g., if during stop the tls_init
handler is removed from the server, con->terminate will cause a crash.