It really depends on the application that is used to open a document. perldoc uses application defined in PERLDOC_PAGER, MANPAGER, or PAGER environmentenvironment variable.
It defaults to less viewer on most systems, so you should press q when browsing the document.
But if by accident you presspressed other keys, you might need to finish the operation before q would allow you to quit.
Wikipedia article on less has its keyboard shortcuts explained in detail.