how to exit a recursive function in c