Implemented close_all in C to better mirror Go code.