Add a method to optionally release the possibly shared factory instance.