Ajaxified form in modal window does not dimiss
I'm not familiar with that ctools command, however try:

$commands = [];

$commands[] = ajax_command_name();

return ['#type' => 'ajax', '#commands' => $commands];

What you ultimately want is for Drupal to receive and render the commands array which should trigger the dismiss and not print the commands to the screen.

(On phone, sorry for formatting)