# Shutdown() method doesn't do anything

**URL:** <https://forum.inductiveautomation.com/t/shutdown-method-doesnt-do-anything/31725>\
**Category:** Module Development\
**Created:** [January 29, 2020, 6:23pm UTC](https://forum.inductiveautomation.com/t/shutdown-method-doesnt-do-anything/31725 "2020-01-29T18:23:59Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![coffeyr](https://avatars.discourse-cdn.com/v4/letter/c/9fc348/32.png) [@coffeyr](https://forum.inductiveautomation.com/u/coffeyr)\
**Post date:** [January 29, 2020, 6:23pm UTC](https://forum.inductiveautomation.com/t/shutdown-method-doesnt-do-anything/31725/1 "2020-01-29T18:23:59Z")

</div>

Hello,

I am working on a developing a module. In the shutdown method of GatewayHook of the module, I’m not sure what to put here to have the module actually shutdown. As of right now, the method gets called, and it puts the message it has into the logger, but the method doesn’t actually do anything else.

I’ve seen where some of the module examples will call super.shutdown(), but since GatewayHook extends an abstract class, it throws an error when I try to do that here.

I am working in Ignition 8.0.5 with Java 11.0.4.

Thank you,

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [January 29, 2020, 6:31pm UTC](https://forum.inductiveautomation.com/t/shutdown-method-doesnt-do-anything/31725/2 "2020-01-29T18:31:31Z")

</div>

`shutdown()` of your hook is called by the gateway when your module is _going_ to shut down - it’s to give _you_ an opportunity to do any clean up or maintenance tasks, before your module’s lifetime stops.

If you want to manually trigger a module shutdown (I’m not sure why, but assuming you have a reason) you need to go from the `GatewayContext` your module gets during `setup`; `GatewayContext.getModuleManager().restartModule(<your module's ID>)`

There’s no independent method to just trigger a ‘shutdown’ - your module is expected to be ‘running’ as long as the gateway is, outside of restarts. If you’re creating some temporary object with its own lifecycle, then you need to manage that bookkeeping yourself; keep a list or map of those objects in your gateway module hook, then in `shutdown`, call `object.destroy()` (or whatever your own objects lifecycle methods are).

---

<div class="post-metadata">

**Author:** ![coffeyr](https://avatars.discourse-cdn.com/v4/letter/c/9fc348/32.png) [@coffeyr](https://forum.inductiveautomation.com/u/coffeyr)\
**Post date:** [January 29, 2020, 6:39pm UTC](https://forum.inductiveautomation.com/t/shutdown-method-doesnt-do-anything/31725/4 "2020-01-29T18:39:04Z")

</div>

Based on your response, I think I might be on the wrong track. I’m currently working on licensing my module, and have gotten it licensed successfully using the API tool, but the Trial version of the module still works outside of the Trial Period on the Gateway.

I found a page that recommended using LicenseState.getLicenseMode() == LicenseMose.Trial and LicenseState.isTrialExpired() to fix this, but assuming both of those are true, I’m not sure what to do next.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [January 29, 2020, 7:47pm UTC](https://forum.inductiveautomation.com/t/shutdown-method-doesnt-do-anything/31725/5 "2020-01-29T19:47:42Z")

</div>

React to license state changes (such as trial expiring) by implementing `notifyLicenseStateChanged(LicenseState)` in your gateway hook. What that means is, again, up to your module/your lifecycle.

For instance, the Webdev module works normally when in trial, or while licensed, but if the trial expires, returns [http 402](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/402). To do this, the various request endpoints (`doGet, doPost`, etc) have a check at the very top - if the cached `LicenseState` on the root module hook returns true for `isTrialExpired()`, then the function immediately returns the 402 status.
