Prevent access through 'NoneType' when closing activity_stream #3907
Although I'm unable to reproduce the issue, its a safe change to
Here's the traceback that occurs without this change...
Although I'm unable to reproduce the issue, its a safe change to prevent an AttributeError from occuring ('NoneType' object has no attribute 'close'). The user that reported this is attempting to launch a kernel and I believe the launch only partially completed such that `kernel._activity_stream` did not get established. (This occurred from Jupyter Enterprise Gateway where we deal with remote kernel launches across resource-managed clusters, so things are a bit more involved relative to kernel establishment.)