Quick fix

Since the program now exits without throwing an exception I had to fix
the threads not being closed.