Each process uses the UnmapViewOfFile function to invalidate the pointer to the mapped memory. This destroys the file view in the address space of the process. If any pages of the file view have changed since the file view was mapped, UnmapViewOfFile also copies the changed pages to the file on disk.
if (!UnmapViewOfFile(lpMapAddress))
{
ErrorHandler("Could not unmap view of file.");
}
When each process finishes using the file-mapping object and has umapped all views, it must close the file mapping object's handle by calling CloseHandle.
CloseHandle(hMapFile);