# Template Creation best practises
> This article is a living document.
<br>
## Prevent double-stop
If this has not been handled in the template's internal logic, the template may flash-in and play-out when Panic, Stop All or other API commands are used to stop the playback or if the Layer Transition is enabled for the template.
To work around this issue, implement a `playing` lifecycle flag.
```js
// State variable
let playing = false;
// In PLAY handler, set the flag
playing = true;
// In STOP handler, check the flag early to prevent Stop when not needed
if (!playing) {return};
```