On any modern OS the heap, open files, and open connections are process resources and will be released on process termination. If you explicitly created a temporary file or shared memory then they will continue to exist until you explicitly remove them, since these are obviously not process-specific.
Something that you can do on Unix filesystems is create/open your temporary file and then immediately unlink()
it. No one else will be able to open it after that but you can still read and write to the file as long as you have it open. If you are sharing the temporary file among multiple processes then you can unlink it after the final process has opened the file. This has the advantage that there will be no need to remove the file on program termination; the disk space will automatically be reclaimed once there are no further references to it and it is no longer open in any process, even if the process was forcibly killed. Windows does not allow you to unlink the file until all processes have closed it, which could make cleanup difficult especially if multiple processes are sharing the same file.