def exit(code=0): preloader.stop() if threading.current_thread().__class__.__name__ == '_MainThread': sys.exit(code) else: thread.exit()