As the question shows that you are in a scrollable output of git log. To exit this you can use:
:q for exit;
:h for help;
Note: if you don’t want to read the output in pager you can use an ENV variable GIT_PAGER to cat or you need to set core.pager to cat.
Hope this will help you to exit the git log.