title: Python Firebase Listener close() Kivy
body: <p>When the Python Kivy application is working, the Firabase Listener also turned on so that it changes the real time values in the application. Listener working fine, my value in firebase db changed.</p>
  <p>But when I close the application, the listener continues to run in the background, and my debug windows didn't close.</p>
  <p>This is a my Firebase listener:</p>
  <pre><code>def listener(event):
      put = event.event_type
      path = event.path
      data = event.data
      print(put)
      print(path)
      print(data)
  
      #do something
  
  listen_on = firebase_admin.db.reference('/my_firebase').listen(listener)
  </code></pre>
  <p>when I run my kivy app I get this output:</p>
  <pre><code>[INFO   ] [Loader      ] using a thread pool of 2 workers
  INFO:kivy:[Loader      ] using a thread pool of 2 workers
  put
  /
  {'mydata1': 20, 'mydata2': 27, 'mydata3': 14, 'mydata4': 15}
  [INFO   ] [Base        ] Start application main loop
  INFO:kivy:[Base        ] Start application main loop
  [INFO   ] [WindowSDL   ] exiting mainloop and closing.
  INFO:kivy:[WindowSDL   ] exiting mainloop and closing.
  [INFO   ] [Base        ] Leaving application in progress...
  INFO:kivy:[Base        ] Leaving application in progress...
  </code></pre>
  <p>Everything works beautifully, data values ​​are changing in the application and the firebase db,</p>
  <p>but, when I close my app, the window with the application closes and I see this in the terminal</p>
  <pre><code>[INFO   ] [Base        ] Leaving application in progress...
  INFO:kivy:[Base        ] Leaving application in progress...
  </code></pre>
  <p>Also my debug windows didnt close yet</p>
  <p>And after closing the app I should see this</p>
  <pre><code>PS J:\Azure\my-code-kivy-firebase
  </code></pre>
  <p>Only after killing the terminal shows the path to my code</p>
  <p>When I add to my code this</p>
  <pre><code>def listener(event):
      put = event.event_type
      path = event.path
      data = event.data
      print(put)
      print(path)
      print(data)
  
      #do something
  
  listen_on = firebase_admin.db.reference('/my_firebase').listen(listener)
  listen_on.close()
  </code></pre>
  <p>My listener stoping and no more change the value in database :(</p>
  <p>I tried to add the <code>listen_on.close()</code> code in various places in the application, but somehow it won't work.</p>
  <p>I tried this:</p>
  <pre><code>try:
      pass
  except:
      listen_on.close()
  </code></pre>
  <p>but it also doesn't work.</p>
  <p>Can someone help me, write where in my code should be <code>listen_on.close()</code> or some other solution. Thank you so much! Keep coding!</p>