I am creating python script to configure router settings remotely but recently  stumbled on problem how to logout or close session after job is done?
From searching I found that Basic-Authentication doesn´t have option to logout. How to solve it in python script?
Basic auth doesn't have a concept of a logout but your router's page should have some implementation. If not, perhaps it has a timeout and you just leave it. 
Since you're using the requests module it may be difficult to do an actual logout if there is no endpoint or parameter for it. I think the best one can do at that point is log in again but with invalid credentials. Studying the structure of the router's pages and the parameters that appear in the urls could give you more options. 
If you want to go a different route and use something like a headless web browser you could actually click a logout button if it exists. Something like Selenium can do this.
Basic-Auth session using python script