use waitforexit combined with kill

fixes #1365