Fix gmagick memory leak

We need to unset gmagick instance to free memory. And unset layers instance because it contains reference to gmagick too.
`isset($this->gmagick) &&` seems unnecessary, since `instanceof` will only eval to `true` when the var to the left is non-null. (yes, the `null !==` check was already obsolete before :-))