The previous fix was putting the FSM towards PICO_SOCKET_STATE_TCP_FIN_WAIT1 not to PICO_SOCKET_STATE_TCP_LAST_ACK. This actually made the fix easier.