If you are running in the foreground, if you started Asterisk such as:
asterisk -gcvvvvvvvvv
If you try the quit command, it won't work, because you are running in the foreground.
Try to connect to the Asterisk console running in background, then use quit or exit:
[root@localhost asterisk]# asterisk -rvvv
localhost*CLI> exit
-r: Connect to Asterisk running in the background and present a Asterisk CLI
-v: The verbose command. Add more āvā:s to get more messages.
Output:
Asterisk cleanly ending (0). Executing last minute cleanups
To check if asterisk is running:
[root@localhost asterisk]# ps -ef | grep asterisk
To stop the Asterisk process:
cli> core stop now
To start the Asterisk service:
[root@localhost asterisk]# service asterisk start
To stop the Asterisk service:
[root@localhost asterisk]# service asterisk stop