This can be done by simply adding:
$('body').click(function(event){
if(event.target.id != 'blue')
$("#green").hide();
});
After the code:
$(document).ready(function() {
$("#blue").click(function() {
$("#green").show();
});
});
This code makes it so that whenever you click on an area that is not the blue div, it will hide the green. You can also input parameters within the hide() function to change how it hides, such as "slow" or "fast"
Live demo with the slow parameter in the function.
You can fiddle around with the parameters to make it how you want it to be when not clicking on it. If you would like it to simply disappear, just leave the .hide() function blank in the parentheses ().