ppel123 32 Newbie Poster

Hello everyone,
I have a problem with my app when closing the gui-UI, that is developed in PyQt5.
In my app I have 3 discrete threads and one of it using slot-signals for communicating with the gui.
The problem I have is that when I close the gui, and the command sys.exit(app.exec_()) is executed the gui closes but the python program still exists in the task manager (I am on Windows).
This is the code that starts the threads and terminates the gui :

if __name__ == "__main__":
    app = QtWidgets.QApplication(sys.argv)
    window = Ui()
    window.move(1600, 900)

    non_suppressed_monitor = keymonitor.KeyMonitor("non_suppressed_monitor", 1, False)
    non_suppressed_monitor.wordPressed.connect(window.on_word_pressed)
    non_suppressed_monitor.enable_disable_hotkey_pressed.connect(window.on_enable_disable_hotkey_press)
    non_suppressed_monitor.start_monitoring()

    suppressed_monitor = keymonitor.KeyMonitor("suppressed_monitor", 2, True)
    suppressed_monitor.start_monitoring()

    keymonitor.event_read_not_suppressed.set()

    thread_delete_and_rewrite = threading.Thread(
        target=corrector_and_rewriter.CorrectorAndRewriter.write_queue_to_screen,
        args=(), daemon=True)
    thread_delete_and_rewrite.start()

    sys.exit(app.exec_())

How can I terminate all threads from the task manager as well, upon the termination of the gui?
Thanks in advance.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.