/*
 * call-seq:
 *   zmq.close() -> nil
 *
 * Terminates the 0MQ context. If there are no longer any sockets open within
 * context at the time zmq_term() is called then context shall be shut down and
 * all associated resources shall be released immediately.
 *
 * Otherwise, the following applies:
 * - The close() function shall return immediately.
 * - Any blocking operations currently in progress on sockets open within
 *   context shall return immediately with an error code of ETERM.
 * - With the exception of ZMQ::Socket#close(), any further operations on
 *   sockets open within context shall fail with an error code of ETERM.
 * - The actual shutdown of context, and release of any associated resources, shall
 *   be delayed until the last socket within it is closed with ZMQ::Socket#close().
 */
static VALUE context_close (VALUE self_)
{
    void * ctx = NULL;
    Data_Get_Struct (self_, void, ctx);
    
    if (ctx != NULL) {
        int rc = zmq_term (ctx);
        assert (rc == 0);

        DATA_PTR (self_) = NULL;
    }

    return Qnil;
}