func isImageMagickCleaned() bool {
	if atomic.LoadInt64(&magickWandCounter) != 0 || atomic.LoadInt64(&drawingWandCounter) != 0 || atomic.LoadInt64(&pixelWandCounter) != 0 {
		return false
	}
	return true
}
Check are all IM objects are collected by GC
package gmagick
import "C"
import (
	"runtime"
	"sync"
	"sync/atomic"
)
var (
	initOnce      sync.Once
	terminateOnce *sync.Once
	canTerminate = make(chan struct{}, 1)
	envSemaphore = make(chan struct{}, 1)
	magickWandCounter  int64
	drawingWandCounter int64
	pixelWandCounter   int64
)
func Initialize() {
	envSemaphore <- struct{}{}
	defer func() {
		<-envSemaphore
	}()
	initOnce.Do(func() {
		C.InitializeMagick(nil)
		terminateOnce = &sync.Once{}
		setCanTerminate()
	})
}
func Terminate() {
	envSemaphore <- struct{}{}
	defer func() {
		<-envSemaphore
	}()
	if terminateOnce != nil {
		terminateOnce.Do(func() {
			runtime.GC()
			terminate()
		})
	}
}
func terminate() {
	<-canTerminate
	C.DestroyMagick()
	initOnce = sync.Once{}
}
func setCanTerminate() {
	if isImageMagickCleaned() {
		select {
		case canTerminate <- struct{}{}:
		default:
		}
	}
}
func unsetCanTerminate() {
	select {
	case <-canTerminate:
	default:
	}
}