Destroy template?

Hey guys,
is there any method that I can call to destroy a template? I’m using a dynamic template to show a user profile in a modal. Problem is, if I visit a second user, the template instance of the first one is still available and I get the old positions in the picture slider (means he shows me picture 3 instead of picture 1). So I want to destroy the template if the user closes my popup.

My current solutions is this:

<div class="popup" id="userPopup">
    {{> Template.dynamic template=showProfilePop.template data=showProfilePop.data}}
</div>

Here is the helper:

Template.registerHelper('showProfilePop', function () {

if(!Session.get('profile_view'))
{
    return {template:null,data:null};
}
else
{
    return {template:'profile',data: Meteor.users.findOne(Session.get('profile_view'), {reactive: false})};
}

});

…and if I open a profile popup:

'click .open-profile': function (e) {

    var self = this;

    Session.set("profile_view", false);


    Meteor.subscribe("userProfile", this._id, function () {
        Session.set("profile_view", self._id);
        myApp.popup("#userPopup");
    });
}

I set profile_view to false, to destroy the current profile template - but is there any better/easier way to solve this?

return {template:null,data:null}; does not destroy any template (template=null). If you want to reset the template just remove the data: return {template: ‘profile’ ,data:null};

In my case it destroys the template, Template.onDestroy() is called when the return value is {template:null,data:null};

I’m using template null for initial app start, because at the beginning the user hasn’t visit any profile.

i just pass null into {{> Template.dynamic }} through a reactive source destroys the template

meteorpad demo