# Error when calling phaserGame.destroy﻿(true)

**URL:** <https://phaser.discourse.group/t/error-when-calling-phasergame-destroy-true/2588>\
**Category:** Phaser 3\
**Created:** [May 27, 2019, 3:12pm UTC](https://phaser.discourse.group/t/error-when-calling-phasergame-destroy-true/2588 "2019-05-27T15:12:28Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kaltin](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/kaltin/32/1460_2.png) [@Kaltin](https://phaser.discourse.group/u/Kaltin)\
**Post date:** [May 27, 2019, 3:12pm UTC](https://phaser.discourse.group/t/error-when-calling-phasergame-destroy-true/2588/1 "2019-05-27T15:12:28Z")

</div>

When I try to call phaserGame.destroy﻿(true) on my game, I get the following JS error:

```javascript
Uncaught TypeError: Cannot read property 'update' of null
    at MatterPhysics.shutdown (MatterPhysics.js?4380:309)
    at MatterPhysics.destroy (MatterPhysics.js?4380:330)
    at EventEmitter.emit (index.js?ba10:202)
    at Systems.destroy (Systems.js?9339:747)
    at SceneManager.destroy (SceneManager.js?cec0:1607)
    at Game.runDestroy (Game.js?22d5:673)
    at Game.step (Game.js?22d5:460)
    at TimeStep.step (TimeStep.js?fdd3:550)
    at step (RequestAnimationFrame.js?7d37:105)

```

Looking at the line number in MatterPhysics.js, it looks like this.world is already null.

```javascript
eventEmitter.off(SceneEvents.UPDATE, this.world.update, this.world);

```

I had found this old topic of how to destroy a Phaser 3 game: [http://www.html5gamedevs.com/topic/32563-whats-the-proper-way-to-destroy-a-phaser-3-game-instance/](http://www.html5gamedevs.com/topic/32563-whats-the-proper-way-to-destroy-a-phaser-3-game-instance/)

Using “Phaser v3.17.0-FB (WebGL | Web Audio)”

---

<div class="post-metadata">

**Author:** ![bradydowling](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/bradydowling/32/1146_2.png) [@bradydowling](https://phaser.discourse.group/u/bradydowling)\
**Post date:** [May 27, 2019, 3:18pm UTC](https://phaser.discourse.group/t/error-when-calling-phasergame-destroy-true/2588/2 "2019-05-27T15:18:02Z")

</div>

Can you post more of your code? Maybe a link to the source?

---

<div class="post-metadata">

**Author:** ![Kaltin](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/kaltin/32/1460_2.png) [@Kaltin](https://phaser.discourse.group/u/Kaltin)\
**Post date:** [May 27, 2019, 4:22pm UTC](https://phaser.discourse.group/t/error-when-calling-phasergame-destroy-true/2588/3 "2019-05-27T16:22:29Z")

</div>

No problem, here’s a Fiddle that reproduces the issue: [https://jsfiddle.net/o8eg5zyn/](https://jsfiddle.net/o8eg5zyn/)  
Just click “Destroy” to see the JS error in your console.

I noticed it doesn’t happen when there is only one scene. It happens when there was a BootScene that loaded the PlayScene.

---

<div class="post-metadata">

**Author:** ![samme](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/samme/32/5275_2.png) [@samme](https://phaser.discourse.group/u/samme)\
**Post date:** [May 27, 2019, 7:36pm UTC](https://phaser.discourse.group/t/error-when-calling-phasergame-destroy-true/2588/4 "2019-05-27T19:36:24Z")

</div>

That may be a Phaser bug, Arcade Physics had a similar problem.
