A queue is closed when its handle is no longer needed and its resources may be freed. When a queue is closed, its handle becomes invalid and all the messages waiting in the queue remain in the queue. This includes any messages sent to the queue by the application closing the queue.
Closing a queue is done with a single call to MQCloseQueue.
hr = MQCloseQueue(hQueue); //handle obtained from MQOpenQueue.
if (FAILED(hr))
{
///////////////////////////////////
// Error handler for MQCloseQueue .
///////////////////////////////////
}