# Module GatewayHook shutdown not called on Gateway stop

**URL:** <https://forum.inductiveautomation.com/t/module-gatewayhook-shutdown-not-called-on-gateway-stop/11105>\
**Category:** 3rd Party Modules\
**Created:** [January 23, 2016, 6:20am UTC](https://forum.inductiveautomation.com/t/module-gatewayhook-shutdown-not-called-on-gateway-stop/11105 "2016-01-23T06:20:12Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yogini\_Marathe](https://avatars.discourse-cdn.com/v4/letter/y/85e7bf/32.png) [@Yogini\_Marathe](https://forum.inductiveautomation.com/u/Yogini_Marathe)\
**Post date:** [January 23, 2016, 6:20am UTC](https://forum.inductiveautomation.com/t/module-gatewayhook-shutdown-not-called-on-gateway-stop/11105/1 "2016-01-23T06:20:12Z")

</div>

Hi,

I am working on a developing a module. In the shutdown method of GatewayHook of the module, I am calling a task to log ShutDown status in the audit database.

What I observed is , this method gets called and record gets added to the database when :

1. Module is restarted from Gateway Home Page -\> Configure -\> Modules
2. Restart the Gateway from gcu (Gateway Control Utility)

However from gcu when I just stop the gateway or stop the gateway service from Task Manager, this shutdown method is not called.

I basically want to track the Gateway shutdown and start through Module GatewayHook shutdown and startup methods.

I am using Ignition version 7.7.5 RC3.

Following is the code for shutdown :

@Override  
public void shutdown() {  
try  
{  
log.error(“gateway shutdown task called”);

```
		//call function to log gateway stop time
		this.gatewayContext.getExecutionManager().executeOnce(new LogGatewayStatus(this.gatewayContext, "GATEWAY_SHUTDOWN"));
	}
	catch(Exception e)
	{
		e.printStackTrace();
		log.error("shutdown hook exception : " + e.getMessage());
	}

```

}

LogGateway Status -\> run method has code to add a record to Audit.

Is there any other way to track gateway shutdown or start ?

Appreciate any help regarding this.

Regards,  
Yogini

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [January 23, 2016, 2:30pm UTC](https://forum.inductiveautomation.com/t/module-gatewayhook-shutdown-not-called-on-gateway-stop/11105/2 "2016-01-23T14:30:16Z")

</div>

I think we fixed a bug that caused the gateway to shutdown immediately, rather than cleanly and orderly, for 7.7.6.
