You can use https://php.net/register_shutdown_function or subscribe to Phalcon\Mvc\Application
application:beforeSendResponse event and modify your HTML, something like:
<?php
$di['eventsManager']->attach(
'application:beforeSendResponse',
function (\Phalcon\Events\Event $event, Phalcon\Mvc\Application $app, Phalcon\Http\Response $response) {
$profiles = 'your html';
// Remove HTML, also preg_replace('/<\/html>\s*$/', ...)
$response->setContent(substr(trim($response->getContent()), 0, -7) . $profiles . '</html>');
}
);