PTR stops running my code as soon as I close the tab