fixes #26: threading error during exit