You can achieve the desired effect by using a pipe to pass in the character “Q”. This makes for a great one-liner for a script:
echo "Q" | openssl s_client -connect host:port
If you are using a sufficiently new version of BASH, you can also use the triple less-than redirect instead of piping (some times a pipe isn’t usable since it operates on stdin/stdout):
openssl s_client -connect host:port <<< "Q"