Free grid_buffer when program exits