Fix stacktrace when context tries to close