Manage the onitu state and close it cleanly