You don't need to restart the computer: As soon as you exit the program, all the used memory is freed.
If you don't use ClearWorld or EndGraphics your program will cause a memory leak so that means;
1.You have to restart your computer or
2.You need a memory cleaner application