You could handle the click event of the document, get the target object, then test if it is the nav div or a child of the nav div. If it is not one of the 2, you can close it.
$(document).on("click", function(e){
var targ = $(e.target);
if (!targ.hasClass("nav") && targ.parents(".nav").length < 1) {
$("div.nav").slideUp();
}
});