I heard the best way is to get into Safe Mode first before you
defrag.
Another way is to close every single program, shut off all
unnecessary processes including your antivirus and firewall,
disconnect from internet totally, disable screensaver and if you
want, kill explorer then you defrag and let it run overnight
without touching it. Make sure the harddisk doesn't go to sleep or
the system going into standby or hibernate