The turn counter is displayed in the bottom right corner, providing the time option is turned on. You start on turn one, and as a rule, everything you do increments the counter. You may occasionally get a "free" turn if you are very fast, due to the speed system.
Most operations relating to the user interface do not consume turns: checking your inventory (including seeing what's inside a container), changing the options, using the far look command, accessing the encyclopedia, using #enhance, saving and restoring, and checking the message buffer ([^P]) are all free.
Quivering projectiles ([Q]) is also free.
The term game length usually refers to the number of turns taken to ascend (or meet some other fate). The turns, or time, taken is highly dependent on your style of play. You may be able to ascend comfortably in 40,000 turns, or you may struggle to gather an ascension kit before 80,000 turns.
Any ascension under 30,000 is widely considered fast, and anything under 20,000 turns is very fast. A small handful of players are able to ascend in under 15,000, while the world record is a mere 2508 turns. The longest game on record at nethack.alt.org is DeathOnAStick's 1.8M turn rock polypiling epic.
It is always possible to quit or escape in one turn, but it is actually possible to die in one turn too (for example, by immediately stepping onto a trap in the first room). You are told "Do not pass go. Do not collect 200 zorkmids."
The turn counter is a long integer, so its maximum value is 2,147,483,647 on 32-bit platforms (and a little over 9 quintillion (9,223,372,036,854,775,808) on 64-bit platforms). There is little danger of this overflowing, even in excruciatingly long extinctionist games.