failure in flusing exe images after termination

I want to flush the image sections of an exe when it is done
executing. I tried doing a MmFlushImageSection in the routine
(registered with PsSetCreateProcessNotifyRoutine) when it is called
for process termination. In the routine I open the file, get object
from handle, get the SOP from the object and pass it to
MmFlushImageSection(). I have tried both FlushForWrite and Delete but
the MmFlushImageSection fails.

What is a good place to call this API from? so that I can flush the
image of the exe when it has terminated?