You should use the Ctrl+D key combination for this.
The combination sends the special
EOF ("End Of File") control character (
^D), which basically tells the terminal that you are done inputting things. This is used to exit out of many interactive shells, like
python's for example.
Alternatively you can try Ctrl+C, which sends the
SIGINT signal to the process in an attempt to end it in a clean way. The
SIGINT signal is usually catched by the process/application itself which allows it to clean up its files or do whatever it wants before exiting. This does not always work to exit out of interactive shells though, instead Ctrl+C is used there to kill a currently running process within the interactive shell. (For example a loop you're running in a python interactive shell)