Call check before callback so the server is closed before the callback
throws an exception