bugfix: terminate properly