<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def api_stop(server_state):
 """ Stop the global API server thread """

    api_srv = server_state['api']

    if api_srv is not None:
        log.info("Shutting down API")
        api_srv.stop_server()
        api_srv.join()
        log.info("API server joined")
    else:
        log.info("API already joined")

    server_state['api'] = None