To exit from the top command in Linux, Unix, BSD, and OS X, you can press the q key. This will close the top command and return you to the command prompt.
Alternatively, you can also use the CTRL + C key combination to exit from top.
If you are running top in interactive mode, you can also use the k command followed by the process ID of the process you want to kill. For example:
k 12345
This will kill the process with ID 12345.
You can also use the h command to view a list of all the available commands and their descriptions.
h
This will display a list of commands that you can use while running top, along with a brief description of each command.