Fix issues that GroupBy and Sample doesn't call 'unsubscribe' and also NPE when the key is null in GroupBy

Fix #1958
I also found `onError` didn't call unsubscribe. For this one, since it will throw an exception, if we call `unsubscribe` in onError, it would be safe.