public void doFinal() throws Throwable {
        for (ShutdownHandler handler : shutdownFunctions) {
            try {
                handler.call();
            } catch (DieException e) {
                finalizeObjects();
                catchUncaught(e);
                break;
            } catch (BaseBaseException | ErrorException e) {
                catchUncaught(e);
                break;
            } catch (Exception e) {
                catchUncaught(e);
                break;
            }
        }

        finalizeObjects();
        flushAll();
        lastMessage = null;
    }
Gets Environment for current thread context
jphp-runtime/src/php/runtime/env/Environment.java