Sessions automatically end when the PHP script finishes executing but can be manually ended using the session_write_close().