A hangup occurs when you disconnect a terminal from the programs running in it. Originally, "hangup" referred to the process of ending a telephone call by placing (or hanging up) the phone on the hook. Some terminals connected to computers using phone lines (for example, with old DOS or Macintosh software like the communication modes of Microsoft Works or AppleWorks) and became subject to hangup. With windowing systems, you can now cause hangups by closing terminal emulators or DOS prompts with programs still running on them. With the Internet, you can cause a hangup by quitting your telnet or ssh client while still running programs. More generally, a hangup is any instance when a parent process quits.
If you hangup while NetHack is running, then (on systems with the SIGHUP signal, such as Unix, VMS and Microsoft Windows), the hangup function at save.c#line83 will save your game. For players who use NetHack's tty interface, an easy way to save the game is to close the terminal emulator or telnet client with NetHack's tty interface inside it.
One of the listed bugs in NetHack 3.4.3 involves some method of using hangup to cheat.