  Consider a stock market following a geometric Brownian motion and a riskless
asset continuously compounded at a constant rate. Assuming the stock can go
bankrupt, i.e., lose all of its value, at some exogenous random time
(independent of the stock price) modeled as the first arrival time of a
homogeneous Poisson process, we study the Merton's optimal portfolio problem
consisting of maximizing the expected logarithmic utility of the total wealth
at a preselected finite maturity time. First, we present a heuristic derivation
based on a new type of Hamilton-Jacobi-Bellman equation. Then, we formally
reduce the problem to a classical controlled Markovian diffusion with a new
type of terminal and running costs. A new version of Merton's ratio is
rigorously derived using Bellman's dynamic programming principle and validated
with a suitable type of verification theorem. A real-world example comparing
the latter ratio to the classical Merton's ratio is given.
