You can use the wp_doing_cron()
method to determine if the request comes from a cron request or not.
if(
defined( 'IN_MAINTENANCE' )
&& IN_MAINTENANCE
&& $pagenow !== 'wp-login.php'
&& ! is_user_logged_in()
&& ! wp_doing_cron()
) {