FIN - a flag set in a TCP packet indicating that one conversant in an current communication has finished sending data.

An ACK flag will (almost) always be piggybacked onto a TCP packet with a FIN set. A recipient of a FIN packet MUST acknowledge the receipt of the FIN by ACKing the received packet and incrementing the sequence number by one (SeqNum+1). Either side of the communicating pair can terminate their end of the communication first. The TCP State of the machine SENDING the FIN will change to FIN_WAIT1 once the FIN has been sent. Upon receipt of an ACK, the TCP State of the sending machine will change to FIN_WAIT2 (indicating that the communication is half-closed.) Upon receipt of a final FIN from the other conversant, the state will change to Closing. Finally, once the final FIN has been ACK'd, the state will change to Closed.

See also TcpStates, and RFC:0793 - Transmission Control Protocol.