As rioV8 said, give focus to the terminal and press q.
In addition, the program can be terminated by ctrl+ C.