handles terminate properly (back/foreground still doesn't quite work)