close the connection after saving

Error 1040: Too many connections when insert many rows.