Bug fix: connection is properly terminated, when TCP is used.