# Help with Plex exit code ("Application" behavior)

**URL:** <https://forums.plex.tv/t/help-with-plex-exit-code-application-behavior/2448>\
**Category:** Dev/API Corner\
**Tags:** plugin-dev\
**Created:** [August 24, 2009, 2:30am UTC](https://forums.plex.tv/t/help-with-plex-exit-code-application-behavior/2448 "2009-08-24T02:30:17Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![trevor.cortez](https://avatars.discourse-cdn.com/v4/letter/t/3be4f8/32.png) [@trevor.cortez](https://forums.plex.tv/u/trevor.cortez)\
**Post date:** [August 24, 2009, 2:30am UTC](https://forums.plex.tv/t/help-with-plex-exit-code-application-behavior/2448/1 "2009-08-24T02:30:17Z")

</div>

Python to exit plex, and listen for re-open
Hi folks,  
  
I'm taking a stab at some plug-in dev, and I'd like to know the code to use to launch an app and listen for it quitting to reopen plex.  
  
I'm using   

```auto

subprocess.call(('open', gamePath))

```

  
to open a game, where gamePath is the path to a rom file. This works to launch it, but there are two problems.  
  
1) Plex is still running in the background  
2) Plex still has control of the Xbox 360 controller  
  
So firstly, I'd like to have plex exit and listen for the emulator application to Quit and automatically relaunch, or I'd like it to at least give up control of the controller temporarily.  
  
Are either of these things the right solution here? Other ideas?

---

<div class="post-metadata">

**Author:** ![jam](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/jam/32/186050_2.png) [@jam](https://forums.plex.tv/u/jam)\
**Post date:** [August 24, 2009, 11:27pm UTC](https://forums.plex.tv/t/help-with-plex-exit-code-application-behavior/2448/2 "2009-08-24T23:27:16Z")

</div>

This won’t be possible from a plug-in (at least not easily). Plug-ins are for the media server, not Plex itself. Plex accesses plug-ins by connecting to a media server - you could theoretically serve multiple copies of Plex from a single plug-in instance. Plug-ins have very little control of Plex beyond sending media lists & triggering playback.

---

<div class="post-metadata">

**Author:** ![trevor.cortez](https://avatars.discourse-cdn.com/v4/letter/t/3be4f8/32.png) [@trevor.cortez](https://forums.plex.tv/u/trevor.cortez)\
**Post date:** [August 24, 2009, 11:30pm UTC](https://forums.plex.tv/t/help-with-plex-exit-code-application-behavior/2448/3 "2009-08-24T23:30:57Z")

</div>

> [@](#):
>
> This won’t be possible from a plug-in (at least not easily). Plug-ins are for the media server, not Plex itself. Plex accesses plug-ins by connecting to a media server - you could theoretically serve multiple copies of Plex from a single plug-in instance. Plug-ins have very little control of Plex beyond sending media lists & triggering playback.

  
  
Hm, could I call the plexhelper from python and tell it to stop listening for xbox controller events?  
  
Otherwise, do you have any suggestions on the best way to get to what I want?

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/plex/original/3X/2/a/2acb9765406f63293d357b4ec509ec39aa28f2ad.png) [@system](https://forums.plex.tv/u/system)\
**Post date:** [December 20, 2019, 8:30pm UTC](https://forums.plex.tv/t/help-with-plex-exit-code-application-behavior/2448/4 "2019-12-20T20:30:17Z")

</div>

Closed on December 20, 2019, 8:30pm UTC

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
