You can call the mysql_close() function to close a previously opened connection.
Syntax
void
mysql_close(MYSQL *mysql)
If the handler was automatically allocated by mysql_init() or mysql_connect(), mysql_close() also deallocates the connection handler to which mysql points.
Return values
None.
Errors
None.