Make sure handles are closed if shared memory mapping fails