For a logout button (assuming there is not a function you can call in the api), you will probably need to know a bit of PHP/small HTML.
For example, this is the code I see when i inspect what Moodle uses to logout of the system
a href="http://domain.ac.uk/login/logout.php?sesskey=sX4acy1PXa"
You need to access the file called logout.php and pass a sessionkey variable. This variable is different every time you log in and different for each user.
The easiest way to do it is to use a hyperlink as above (and just use css to make it look like a button) that links to /login/logout.php
Before coding the link, you need to get the session variable for the current user so you can pass it to the logout.php file as above: ?sesskey=blah blah
This allows the system to know who to logout.
To get the sesskey you will need something like$_GET['session_key'] but that may not be safe so I would read the logout.php file and see how they got the key there and copy that method.
Hope that helps