Problem Link to heading You have a constructor function that creates an object with a background goroutine. You want the object to garbage collect itself even if people don’t explicitly close it. This isn’t possible since since the background goroutine is always running and pointing to your created object. Solution Link to heading Wrap the returned object and use a finalizer on the returned object to shut down the background goroutine.