## nn_term

Terminate library (compatible API).

### Synopsis

```c
#include <nanomsg/nn.h>

void nn_term(void);
```

### Description

The `nn_term` function closes any open sockets, and frees all resources allocated by the library.
Any operations that are currently in progress will be terminated, and will fail with error `EBADF` or `ETERM`.

IMPORTANT: This function is not thread-safe, and is not suitable for use in library calls.
The intended purpose of this is to clean up at application termination.
This can help prevent false leak reports caused when memory checkers notice global resources allocated by the library.
Libraries should never use this function, but should explicitly close their own sockets directly.

### See Also

xref:nn_errno.adoc[nn_errno],
xref:nn_socket.adoc[nn_socket]