One way to do it is to use jQuery and a script to hide if messages are present:
<apex:outPutPanel layout="block" id="the_panel">
....your content here....
if($('[id$=msgs]').html() == '') $('[id$=the_panel]').hide();
During an action simply serenader the_panel and the script will hide it if the msgs component has a message in it
Without knowing exactly what you are doing before, during, or after your code execution this is only an example of one possible way to do it. There may/will be better ways to do it depending on your page and apex code. This way has a downside of the panel possibly briefly being visible before it is hidden