actually it's a problem for me i could not fix too , but here is a solution for your problem without any library or something :
$(document).on("pageinit", function () {
$("[data-role=panel] a").on("click", function () {
if($(this).attr("href") == "#"+$.mobile.activePage[0].id) {
$("[data-role=panel]").panel("close");
}
});
});
which check if the hash of your target is the same like the current one then it close the panel . hope this help .
and here is a live demo : jsfiddle
you can refer to this post :