Close the entity manager factory if it exists and is in open state per JPA Spec section
5.8.1.
343856
final void close() {
        final boolean isTraceOn = TraceComponent.isAnyTracingEnabled();
        if (isTraceOn && tc.isEntryEnabled())
            Tr.entry(tc, "close : " + ivArchivePuId, this);

        // First, prevent any further EntityManager factories from being
        // created. EMFs may be created for each java:comp/env context.
        if (ivEMFMap != null) {
            synchronized (ivEMFMap) {
                ivCreateEMFAllowed = false;
            }
        }

        // Next, shutdown any EntityManager pools that exist.  This will close
        // all of the pooled EMs and prevent the pools from adding any more EMs.
        // This does NOT close any EMs that customers may be actively using...
        // and it is also possible a new pool may be created prior to closing
        // the EMFs below, but the EMF close is gauranteed to close all EMs
        // associated with it.                                             d510184
        synchronized (ivEMPoolMap) {
            if (isTraceOn && tc.isDebugEnabled())
                Tr.debug(tc, "shutting down EM pools : " + ivEMPoolMap.size());

            for (JPAEMPool emPool : ivEMPoolMap.values()) {
                emPool.shutdown();
            }
        }

        unregisterClassFileTransformer(ivClassLoader);

        // Finally, close the base EMF, and any EMFs that have been created
        // for each java:comp/env.
        if (ivEMFactory != null) {
            // d455363 Begins
            if (ivEMFactory.isOpen()) {
                try {
                    if (isTraceOn && tc.isDebugEnabled())
                        Tr.debug(tc, "closing base EMF");
                    ivEMFactory.close();
                } catch (Exception e) {
                    FFDCFilter.processException(e, CLASS_NAME + ".close",
                                                "934", this);

                    if (isTraceOn && tc.isDebugEnabled())
                        Tr.debug(tc, "Caught unexpected exception on factory.close():" + e);
                }
            }
            // d455363 Ends

            // Close all of the factories for each J2EEName when the datasource
            // is defined in java:comp/env.                                 d510184
            if (ivEMFMap != null) {
                for (EntityManagerFactory emFactory : ivEMFMap.values()) {
                    if (emFactory.isOpen()) {
                        try {
                            if (isTraceOn && tc.isDebugEnabled())
                                Tr.debug(tc, "closing component EMF");
                            emFactory.close();
                        } catch (Exception e) {
                            FFDCFilter.processException(e, CLASS_NAME + ".close",
                                                        "934", this);

                            if (isTraceOn && tc.isDebugEnabled())
                                Tr.debug(tc, "Caught unexpected exception on factory.close():" + e);
                        }
                    }
                }
            }
        }

        if (isTraceOn && tc.isEntryEnabled())
            Tr.exit(tc, "close : " + ivArchivePuId);
    }
402469
public boolean close()
    {
        if (getDelegate() == null) return true;
        try
        {
            PersistenceBrokerThreadMapping.unsetCurrentPersistenceBroker(getPBKey(), this);
            super.close();
        }
        finally
        {
            /*
            here we destroy the handle. set the
            underlying PB instance 'null', thus it's not
            possible to corrupt a closed PB instance.
            */
            setDelegate(null);
        }
        return true;
    }
880195
public static void close(Object... objsToClose) {
		for (Object obj : objsToClose) {
			if (obj instanceof AutoCloseable) {
				IoUtil.close((AutoCloseable) obj);
			} else if (obj instanceof Closeable) {
				IoUtil.close((Closeable) obj);
			} else {
				try {
					if (obj != null) {
						if (obj instanceof ResultSet) {
							((ResultSet) obj).close();
						} else if (obj instanceof Statement) {
							((Statement) obj).close();
						} else if (obj instanceof PreparedStatement) {
							((PreparedStatement) obj).close();
						} else if (obj instanceof Connection) {
							((Connection) obj).close();
						} else {
							log.warn("Object {} not a ResultSet or Statement or PreparedStatement or Connection!", obj.getClass().getName());
						}
					}
				} catch (SQLException e) {
					// ignore
				}
			}
		}
	}
1288109
@Nullable
    private SessionFactory unwrap(EntityManagerFactory entityManagerFactory) {
        try {
            return entityManagerFactory.unwrap(SessionFactory.class);
        } catch (PersistenceException ex) {
            return null;
        }
    }
1168540
private function clearEntityManagers()
    {
        foreach ($this->managerRegistry->getManagers() as /* @var $manager EntityManager */ $manager) {
            if (!$manager instanceof EntityManager) {
                continue;
            }
            $manager->clear();
            if (!$manager->getConnection()->ping()) {
                $manager->getConnection()->close();
                $manager->close();
            }
        }
    }
570953
public void close() 
  throws SIResourceException, SIConnectionLostException,
         SIErrorException
  {
    if (CoreSPIBifurcatedConsumerSession.tc.isEntryEnabled()) 
      SibTr.entry(CoreSPIBifurcatedConsumerSession.tc, "close", this);
    
    boolean closedNow =_close();
    
    // If this close operation actually closed the consumer, then
    // remove the consumer from the list stored in the connection
    // Also remove the Consumer from the list store in the Consumer
    // Session.
    if (closedNow)
    {
      _connection.removeBifurcatedConsumerSession(this);
    }
    
    if (CoreSPIBifurcatedConsumerSession.tc.isEntryEnabled()) 
      SibTr.exit(CoreSPIBifurcatedConsumerSession.tc, "close");
  }
1370189
public void close()
                    throws ObjectManagerException
    {
        if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
            trace.entry(this,
                        cclass,
                        "Close");

        try {
            dataInputStream.close();
            sectorValidatedInputStream.close();

        } catch (java.io.IOException exception) {
            // No FFDC Code Needed.
            ObjectManager.ffdc.processException(cclass, "close", exception, "1:98:1.13");

            if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
                trace.exit(this, cclass
                           , "close"
                           , exception
                                );
            throw new PermanentIOException(this
                                           , exception);
        } // catch (java.io.IOException exception).  

        if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
            trace.exit(this, cclass
                       , "close"
                            );
    }
186434
public static void safeClose(@Nullable Closeable closeable) {
        if (closeable == null) return;

        try {
            closeable.close();
        } catch (IOException ignored) {
            // We made out best effort to release this resource. Nothing more we can do.
        }
    }
893236
public void close(Context context) {
        client.clean(context.getApplicationContext());
        if (db != null) {
            db.closeDatabase();
        }
    }
174495
static public void close(FileSystemManager fsManager){
		if (fsManager != null){
			if (fsManager instanceof DefaultFileSystemManager){
				((DefaultFileSystemManager) fsManager).close();
			}else{
				throw new IllegalStateException("Only instance of DefaultFileSystemManager can be closed here.");
			}
		}
	}
151685
public void close() {
        synchronized(factory.cnxns){
            // if this is not in cnxns then it's already closed
            if (!factory.cnxns.remove(this)) {
                return;
            }

            synchronized (factory.ipMap) {
                Set<NIOServerCnxn> s =
                    factory.ipMap.get(sock.socket().getInetAddress());
                s.remove(this);
            }

            // unregister from JMX
            try {
                if(jmxConnectionBean != null){
                    MBeanRegistry.getInstance().unregister(jmxConnectionBean);
                }
            } catch (Exception e) {
                LOG.warn("Failed to unregister with JMX", e);
            }
            jmxConnectionBean = null;

            if (zk != null) {
                zk.removeCnxn(this);
            }

            closeSock();

            if (sk != null) {
                try {
                    // need to cancel this selection key from the selector
                    sk.cancel();
                } catch (Exception e) {
                    if (LOG.isDebugEnabled()) {
                        LOG.debug("ignoring exception during selectionkey cancel", e);
                    }
                }
            }
        }
    }
1084807
public void checkpoint(ObjectEnvelope mod) throws PersistenceBrokerException
    {
        mod.doInsert();
        mod.setModificationState(StateOldClean.getInstance());
    }
448724
@Nonnull
  public EntityManager createEntityManager (@SuppressWarnings ("rawtypes") final Map aMap)
  {
    // Create entity manager (factory may be null - e.g. after close)
    final EntityManager aEntityManager = getEntityManagerFactory ().createEntityManager (aMap);
    if (aEntityManager == null)
      throw new IllegalStateException ("Failed to create EntityManager from factory " +
                                       m_aFactory +
                                       " with parameters " +
                                       aMap +
                                       "!");
    return aEntityManager;
  }
738374
@Override
	public void close() {
		transactionManager.close();
		if (coverageHandlerRef.get() != null) {
			coverageHandlerRef.get().onSqlAgentClose();
		}
	}
97810
public static void closeQuietly(final MessageProducer producer)
    {
        if (producer != null) {
            try {
                producer.close();
            }
            catch (JMSException je) {
                if (je.getCause() instanceof InterruptedException) {
                    LOG.trace("ActiveMQ caught and wrapped InterruptedException");
                }
                if (je.getCause() instanceof InterruptedIOException) {
                    LOG.trace("ActiveMQ caught and wrapped InterruptedIOException");
                }
                else {
                    LOG.warnDebug(je, "While closing producer");
                }
            }
        }
    }
1244783
@Override
    public void close()
    {
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
            Tr.debug(tc, "close : " + this);
        throw new UnsupportedOperationException("This operation is not supported on a pooling EntityManagerFactory.");
    }
273467
@Invalidate
    void shutdown() {
        if (repository != null) {
            repository.dispose();
        }

        if (emRegistration != null) {
            emRegistration.unregister();
        }
        if (entityManager != null) {
            entityManager.close();
        }
        if (emfRegistration != null) {
            emfRegistration.unregister();
        }
        if (entityManagerFactory != null) {
            entityManagerFactory.close();
        }
        if (transformer != null) {
            transformer.unregister(sourceBundle.bundle);
        }
    }