Deallocate dynamic memory in the matrix path problem.