Fixes shared memory file leaks