Cleans up the primary event handler.