---
title: "Unit Shutdown JavaScript"
description: "execute JavaScript when pipeline units shut down."
source: "https://github.com/log-10x/modules/tree/main/pipelines/run/units/transform/script/unitShutdown/unit.yaml"
icon: "material/power-plug-off-outline"

---
Execute JavaScript when [pipeline units](https://doc.log10x.com/engine/pipeline/#units) shut down.

Unit `close()` methods are the shutdown counterpart to `constructor()` methods.
They execute while the unit is still fully functional, before its internal shutdown sequence begins.

```js
// @loader: tenx

import {TenXUnit, TenXEnv, TenXConsole} from '@tenx/tenx'

export class SymbolLoaderUnit extends TenXUnit {

    static shouldLoad(config) {
       return !TenXEnv.get("quiet") && (config.unitName == "symbolLoader");
    }

    constructor() {
        TenXConsole.log("Loading symbol libraries from: " + this.symbolPaths);
    }

    close() {
        TenXConsole.log("Shutting down symbol loader: " + this.unitName);
    }
}
```

Both `constructor()` and `close()` are defined in the same TenXUnit subclass.
The `shouldLoad(config)` method applies to both, if a class is not loaded for a given unit, neither its constructor nor its close method will execute.

To load unit scripts see [JavaScript configuration](https://doc.log10x.com/config/javascript/).

## :material-menu: Options

Specify the options below to [configure](/config "configure") multiple Unit Shutdown JavaScript:

|Name|Description|
|---|---|
|[unitShutdownActionsClassName](#unitshutdownactionsclassname "JavaScript class name")|JavaScript class name|
|[unitShutdownActions](#unitshutdownactions "10x JavaScript shutdown statements to execute")|10x JavaScript shutdown statements to execute|
|[unitShutdownActionsFile](#unitshutdownactionsfile "Declaring .js file")|Declaring .js file|

### :material-menu-right-outline:**`unitShutdownActionsClassName`**

JavaScript class name.

|Type|Required|Names|
|---|---|---|
|String|✔|\[unitShutdownActionsClassName, TenXUnitShutdownClassName\]|

Specifies the JavaScript class name in which [unitShutdownActions](https://doc.log10x.com/run/transform/script/unit/#unit-shutdown) are defined.


### :material-menu-right-outline:**`unitShutdownActions`**

10x JavaScript shutdown statements to execute.

|Type|Default|Names|
|---|---|---|
|List|\[\]|\[unitShutdownActions, TenXUnitShutdown\]|

JavaScript statements for shutting down target unit(s).

**NOTE**: This argument is not designed to be set directly, but instead by passing a [.js launch file](https://doc.log10x.com/config/javascript/) containing
these statements nested within a [TenXUnit](https://doc.log10x.com/api/js/#TenXUnit "Serves as a base class to allow for custom pipeline unit initialization and shutdown.") sub-class close() method.


### :material-menu-right-outline:**`unitShutdownActionsFile`**

Declaring .js file.

|Type|Default|Names|
|---|---|---|
|String|""|\[unitShutdownActionsFile, TenXUnitShutdownFile\]|

Specifies the .js file name declaring [unitShutdownActions](https://doc.log10x.com/run/transform/script/unit/#unit-shutdown).


<br/>:material-github: This unit is defined in [unitShutdown/unit.yaml](https://github.com/log-10x/modules/tree/main/pipelines/run/units/transform/script/unitShutdown/unit.yaml "unitShutdown/unit.yaml"){target="\_blank"}.

