It goes without saying that open files ought to be closed. This is automatically performed by the kernel when the a process exits, but since the number of available file descriptors is strictly limited, it's always a good practice to close files when they are not needed anymore.
File closing is performend by the close() system call, declared as
int close(int fildes);The argument is the file descriptor of the file to be closed, and of course an error if reported if you pass a wrong (i.e. unopened) one.