protected void terminatePending() {
        AppState[] array = getTerminating();
        if (array.length == 0)
            return;

        for (AppState state : array) {
            state.cleanup();
        }
        synchronized (states) {
            // Remove just the states that were terminated...
            // which might now be a subset of the total terminating
            // list.
            terminating.removeAll(Arrays.asList(array));
        }
    }
Returns the state associated with the specified ID at the time it
 was attached or throws an IllegalArgumentException if the ID was
 not found.

@param <T> the desired type of AppState
@param id the AppState ID
@param stateClass the desired type of AppState
@return the pre-existing instance (not null)
jme3-core/src/main/java/com/jme3/app/state/AppStateManager.java