My program in python runs on RaspBerry Pi, and instantiates several objects (GPIO inputs and outputs, http server, webSocket, I2C interface, etc..., with thread).
When exiting my program, I try to clear all the resources, and delete all the instances.
For the network objects, I close listening sockets and so on.
I finish with a sys.exit() call, but program doe not exit and does not returns alone to linux console (I need to press ctrl+z).
Are there some objects that are not released, how to know, and how to force exit ?
Best regards.
I had a similar problem programming a simple GPIO app on the Pi. I was using the GPIOZero library, and as their code examples suggest, I was waiting for button pushes using signal.pause(). This would cause the behavior you describe - even sys.exit() would not exit!
The solution was, when it was time for the code to finish, to do this:
# Send a SIGUSER1 signal; this will cause signal.pause() to finish.
  os.kill(os.getpid(), signal.SIGUSR1)

You don't even have to define a signal handler if you don't mind the system printing out "User defined signal 1" on the console.
HTH
How to exit python program on raspberry