Is is ethical to not compensate experiment participants who withdraw from the study? I do experiments on learning and instruction for my dissertation. They are almost no risks in participating in our studies--except maybe boredom since they tend to run for 30 minutes to 1 hour. We get a lot of unmotivated students who don't really take the experiment tasks seriously. But in spite of this, they never get penalized if they complete the experiment. That means they get their compensation (money or course credit) and we don't check their answers before they walk out of the lab.

However, what should I do if a student withdraws participation? Should they still be given monetary compensation or course credit? Would it be ethical to specify that they will only be compensated if they complete the study? This hasn't happened to me yet, but I am running an online study and it will be harder to keep track of whether participants really complete the study or not.
I don't see any ethical problem in not compensating people for work they don't do. However, you still have to frame the problem in a clear way in order to avoid frustration/litigations. Just write down explicitely that a student will receive compensation only if he/she completes the test. 

As for motivating students to give you meaningful answer, that is a completely different story, and a much more complex one.