Fix gmagick memory leak

We need to unset gmagick instance to free memory. And unset layers instance because it contains reference to gmagick too.
> I don't want to introduce the memory management in the API. We use PHP because we don't want to handle this.

Unfortunately, when in unit tests appeared the line "gc_disable()", it was actually the disabling of php garbage collection, the main mechanizm of php memory management