I have only used Macs for 15 years, and worked for Apple six of those years, but here is my take:
-- "compiling a video" means... I don't know what. The typical processes in iMovie are these:
* import -- means to add a file to the project.
* save -- means to cause iMovie to save the project both as a finished video file inside the project bundle that shows what you created, and also save the effects in a database so that you could open the project again and change the effects, remove one or more effects, or add more effects.
* share -- means to convert the default format of the movie file into some other format, and save it as a second file outside the project.
For the best possible answers abut any app, mention the exact version, such as iMovie '09 or '11.
I wish to holy heck that Apple would include a sticker on the lid of every notebook computer that says: "DO NOT CLOSE THE LID UNLESS YOU WANT TO PUT THE COMPUTER TO SLEEP."
You see, it's like this: There are only three normal states for a computer system:
-- Off. {This means nothing is happening because there is no electrical power going through the computer.}
-- Up and running. {This means the OS is loaded and one or more apps can be used normally.}
-- Sleep. {This means the computer IS NOT UP AND RUNNING, but is in a type of "stand-by" mode waiting to be put back in the up-and-running mode. NO APPS CAN DO ANYTHING IN SLEEP. If apps are in the middle of doing something, putting the computer to sleep will pull the rug from under EVERYTHING, so do not close the lid. Sleep STOPS THE HDD FROM SPINNING.}
If you want to know if the HDD file system (talking software only here, but very important software) can be damaged by suddenly stopping the HDD from spinning while files are writing to it, the answer is yes. If you want to know if damage to the file system is GUARANTEED every time you stop the HDD from spinning while files are in the process of writing to it, the answer is no.
Lastly, if you want to know how to get out of an OBVIOUS hang of a process (importing, saving, sharing) that has been going on much longer than you can imagine makes any sense, it is by Force Quit (option ⌘ ESC). When that fails, you have no choice but to press and hold the power button for 10 seconds. Closing the lid is not useful or recommended for any reason except to put the system to sleep when no apps are doing anything that involves reading from or writing to the HDD.