Fix x11grab shared memory leak

Fixes https://trac.ffmpeg.org/ticket/3169